Subject | Hash | Author | Date (UTC) |
---|---|---|---|
Create controller and resource to create new vehicle | a1c21acba62f5070cc61ffc4910218be3e52b052 | Antonio Calatayud | 2018-12-19 15:50:37 |
New vehicle model for context | 1040629cd4f2931f0c4ebee6f5c505ebaff3d97b | Antonio Calatayud | 2018-11-26 17:43:04 |
Finish form | 291cafcfa67fbfec687fc2d58e4fb70e8cb11975 | Antonio Calatayud | 2018-11-26 16:31:54 |
Merge services | 385e874ea56eb15a14f983e94d5cbd444cc13ba7 | Antonio Calatayud | 2018-11-16 22:40:25 |
Populate feature checkboxes | 1d31b1b0f70c96ceb04f375bb28affbdcc6bbf93 | Antonio Calatayud | 2018-11-16 22:30:32 |
Create Feature Service | 83633fa68f9ceb113974f8cfa1cbad527dcb1730 | Antonio Calatayud | 2018-11-16 22:21:55 |
Add cascade dropdown for model | 23a3a4509386c52d83df8e2742260b31d74d2c31 | Antonio Calatayud | 2018-11-16 22:14:27 |
Populate dropdown list of makes | 2f990816aa06a5c1157792e7194118e8f27edd01 | Antonio Calatayud | 2018-11-16 21:57:05 |
Create service to bring makes | 4392eaef90093371844491026c771439cb43907e | Antonio Calatayud | 2018-11-16 21:54:02 |
Start form | 73244c2b63ba957d2a8212d32b7a18114a6a4e72 | Antonio Calatayud | 2018-11-16 21:52:19 |
Add routing to new component | 51ae297856214503a62716a9fc841db611cb7b1e | Antonio Calatayud | 2018-11-16 21:22:58 |
Create new component for vehicle form | 774a1e6105d82f115c5002db0b6a66429f7d7f04 | Antonio Calatayud | 2018-11-16 21:13:06 |
Add API with mapping | e2a22c67e3d34c4125adf5bec2c3b1dd319b999b | Antonio Calatayud | 2018-11-13 18:14:15 |
Add feature Model and seed | 83b852e4e3e045b110d412d4c072cffdd43b5015 | Antonio Calatayud | 2018-11-13 17:56:09 |
Create api for makes with mapping | 0090cccd2af8016cc3d8ebe0c690ec9c8be1f9ba | Antonio Calatayud | 2018-11-13 17:16:29 |
Seed DB with test records | 290f03be73cde265adeb436d9083f848e335d0ad | Antonio Calatayud | 2018-11-13 13:00:38 |
Add first Migration | f7dbe278633d37cb84371ff9872f2999d1551d23 | Antonio Calatayud | 2018-11-13 11:18:29 |
Add DbContext | 63523201e374cd186a873d405395cec6eefd989d | Antonio Calatayud | 2018-11-13 11:13:33 |
Add models | 10cb5370ddb34a9afdaa0ae964c2ee540821462b | Antonio Calatayud | 2018-11-09 18:11:22 |
First commit | 3033c730b731b08ad5198975d238635007575714 | Antonio Calatayud | 2018-11-09 17:09:28 |
File | Lines added | Lines deleted |
---|---|---|
Controllers/Resources/ContactResource.cs | 18 | 0 |
Controllers/Resources/VehicleResource.cs | 23 | 0 |
Controllers/VehiclesController.cs | 24 | 0 |
Mapping/MappingProfile.cs | 9 | 0 |
Models/Vehicle.cs | 2 | 1 |
File Controllers/Resources/ContactResource.cs added (mode: 100644) (index 0000000..254df5f) | |||
1 | using System.ComponentModel.DataAnnotations; | ||
2 | |||
3 | namespace vega.Controllers.Resources | ||
4 | { | ||
5 | public class ContactResource | ||
6 | { | ||
7 | [Required] | ||
8 | [StringLength(255)] | ||
9 | public string Name { get; set; } | ||
10 | |||
11 | [Required] | ||
12 | [StringLength(255)] | ||
13 | public string Phone { get; set; } | ||
14 | |||
15 | [StringLength(255)] | ||
16 | public string Email { get; set; } | ||
17 | } | ||
18 | } |
File Controllers/Resources/VehicleResource.cs added (mode: 100644) (index 0000000..e8fca0d) | |||
1 | using System.Collections.Generic; | ||
2 | using System.Collections.ObjectModel; | ||
3 | using System.ComponentModel.DataAnnotations; | ||
4 | using vega.Models; | ||
5 | |||
6 | namespace vega.Controllers.Resources | ||
7 | { | ||
8 | public class VehicleResource | ||
9 | { | ||
10 | public VehicleResource() | ||
11 | { | ||
12 | Features = new Collection<int>(); | ||
13 | } | ||
14 | public int Id { get; set; } | ||
15 | [Required] | ||
16 | public int ModelId { get; set; } | ||
17 | public bool IsRegistered { get; set; } | ||
18 | public ContactResource Contact { get; set; } | ||
19 | |||
20 | public ICollection<int> Features { get; set;} | ||
21 | |||
22 | } | ||
23 | } |
File Controllers/VehiclesController.cs added (mode: 100644) (index 0000000..4b2f0a2) | |||
1 | using AutoMapper; | ||
2 | using Microsoft.AspNetCore.Mvc; | ||
3 | using vega.Controllers.Resources; | ||
4 | using vega.Models; | ||
5 | |||
6 | namespace vega.Controllers | ||
7 | { | ||
8 | [Route("/api/vehicles")] | ||
9 | public class VehiclesController : Controller | ||
10 | { | ||
11 | private readonly IMapper mapper; | ||
12 | public VehiclesController(IMapper mapper) | ||
13 | { | ||
14 | this.mapper = mapper; | ||
15 | } | ||
16 | |||
17 | [HttpPost] | ||
18 | public IActionResult CreateVehicle([FromBody] VehicleResource vehicleResource) | ||
19 | { | ||
20 | var vehicle = mapper.Map<VehicleResource, Vehicle>(vehicleResource); | ||
21 | return Ok(vehicle); | ||
22 | } | ||
23 | } | ||
24 | } |
File Mapping/MappingProfile.cs changed (mode: 100644) (index 12df4fb..ca28040) | |||
1 | using System.Linq; | ||
1 | 2 | using AutoMapper; | using AutoMapper; |
2 | 3 | using vega.Controllers.Resources; | using vega.Controllers.Resources; |
3 | 4 | using vega.Models; | using vega.Models; |
... | ... | namespace vega.Mapping | |
8 | 9 | { | { |
9 | 10 | public MappingProfile() | public MappingProfile() |
10 | 11 | { | { |
12 | // Domain to API Resource | ||
11 | 13 | CreateMap<Make, MakeResource>(); | CreateMap<Make, MakeResource>(); |
12 | 14 | CreateMap<Model, ModelResource>(); | CreateMap<Model, ModelResource>(); |
13 | 15 | CreateMap<Feature, FeatureResource>(); | CreateMap<Feature, FeatureResource>(); |
16 | |||
17 | // API Resource to Domain | ||
18 | CreateMap<VehicleResource, Vehicle>() | ||
19 | .ForMember(v => v.ContactName, opt => opt.MapFrom(vr => vr.Contact.Name)) | ||
20 | .ForMember(v => v.ContactPhone, opt => opt.MapFrom(vr => vr.Contact.Phone)) | ||
21 | .ForMember(v => v.ContactEmail, opt => opt.MapFrom(vr => vr.Contact.Email)) | ||
22 | .ForMember(v => v.Features, opt => opt.MapFrom(vr => vr.Features.Select(id => new VehicleFeature{ FeatureId = id }))); | ||
14 | 23 | } | } |
15 | 24 | } | } |
16 | 25 | } | } |
File Models/Vehicle.cs changed (mode: 100644) (index 05beab4..1f2cf91) | |||
... | ... | namespace vega.Models | |
29 | 29 | public string ContactPhone { get; set; } | public string ContactPhone { get; set; } |
30 | 30 | ||
31 | 31 | [StringLength(255)] | [StringLength(255)] |
32 | public string ContactEmail { get; set; } public DateTime LastUpdate { get; set; } | ||
32 | public string ContactEmail { get; set; } | ||
33 | public DateTime LastUpdate { get; set; } | ||
33 | 34 | } | } |
34 | 35 | } | } |