List of commits:
Subject Hash Author Date (UTC)
Start implementing repository pattern 1d0b0cd78bc861d0e0282a69e5d88b219efbb118 Antonio Calatayud 2019-01-06 17:37:57
Return all inf when update/added vehicle ef44980290b644244de12ad9e064ca6dcee0ac2b Antonio Calatayud 2019-01-04 16:51:50
Refactor to bring different vehicle resources between get & update/add 6980669ec37dab31b595af6fa1be6718eef4b4e1 Antonio Calatayud 2019-01-04 16:37:41
Implemented Get Vehicle d340e1c7dda6424e1e370465be03e4e7a74c0b3e Antonio Calatayud 2019-01-04 15:45:26
Implemented delete vehicle a07116dd194b102098b3e826680d374ad6f3660e Antonio Calatayud 2019-01-04 15:32:13
Implement update vehicle d52a39f524983c681a190023a40337425432c7a6 Antonio Calatayud 2019-01-04 15:23:19
Add Validation when creating a vehicle 7a0f75bba8507110d9d8e801969cdf7497fa15a8 antonio.calatayud 2019-01-02 16:40:39
Add vehicle to database capability fa84eb5a526a124b4ec7126271052611e0f57bb1 antonio.calatayud 2019-01-02 16:22:18
Fix Migrations e540688f04b874a8f3f5c95c6f31c640440b2921 antonio.calatayud 2019-01-02 15:51:37
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
Commit 1d0b0cd78bc861d0e0282a69e5d88b219efbb118 - Start implementing repository pattern
Author: Antonio Calatayud
Author date (UTC): 2019-01-06 17:37
Committer name: Antonio Calatayud
Committer date (UTC): 2019-01-06 17:37
Parent(s): ef44980290b644244de12ad9e064ca6dcee0ac2b
Signer:
Signing key:
Signing status: N
Tree: 5b891598017efdb6c522bb1a56114fc10a66547d
File Lines added Lines deleted
Controllers/VehiclesController.cs 8 19
Core/Repositories/IVehicleRepository.cs 11 0
Persistence/Repositories/VehicleRepository.cs 25 0
Startup.cs 4 0
File Controllers/VehiclesController.cs changed (mode: 100644) (index 660989a..f874130)
... ... using AutoMapper;
4 4 using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
5 5 using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
6 6 using vega.Controllers.Resources; using vega.Controllers.Resources;
7 using vega.Core.Repositories;
7 8 using vega.Models; using vega.Models;
8 9 using vega.Persistence; using vega.Persistence;
9 10
 
... ... namespace vega.Controllers
14 15 { {
15 16 private readonly IMapper mapper; private readonly IMapper mapper;
16 17 private readonly VegaDbContext context; private readonly VegaDbContext context;
18 private readonly IVehicleRepository repository;
17 19
18 20 public VehiclesController( public VehiclesController(
19 21 IMapper mapper, IMapper mapper,
20 VegaDbContext context)
22 VegaDbContext context,
23 IVehicleRepository repository)
21 24 { {
22 25 this.mapper = mapper; this.mapper = mapper;
23 26 this.context = context; this.context = context;
27 this.repository = repository;
24 28 } }
25 29
26 30 [HttpPost] [HttpPost]
 
... ... namespace vega.Controllers
42 46 context.Vehicles.Add(vehicle); context.Vehicles.Add(vehicle);
43 47 await context.SaveChangesAsync(); await context.SaveChangesAsync();
44 48
45 vehicle = await context.Vehicles
46 .Include(v => v.Features)
47 .ThenInclude(vf => vf.Feature)
48 .Include(v => v.Model)
49 .ThenInclude(m => m.Make)
50 .SingleOrDefaultAsync(v => v.Id == vehicle.Id);
49 vehicle = await repository.GetVehicle(vehicle.Id);
51 50
52 51 var result = mapper.Map<Vehicle, VehicleResource>(vehicle); var result = mapper.Map<Vehicle, VehicleResource>(vehicle);
53 52 return Ok(result); return Ok(result);
 
... ... namespace vega.Controllers
59 58 if (!ModelState.IsValid) if (!ModelState.IsValid)
60 59 return BadRequest(ModelState); return BadRequest(ModelState);
61 60
62 var vehicle = await context.Vehicles
63 .Include(v => v.Features)
64 .ThenInclude(vf => vf.Feature)
65 .Include(v => v.Model)
66 .ThenInclude(m => m.Make)
67 .SingleOrDefaultAsync(v => v.Id == id);
61 var vehicle =await repository.GetVehicle(id);
68 62
69 63 if (vehicle == null) if (vehicle == null)
70 64 return NotFound(); return NotFound();
 
... ... namespace vega.Controllers
95 89 [HttpGet("{id}")] [HttpGet("{id}")]
96 90 public async Task<IActionResult> GetVehicle(int id) public async Task<IActionResult> GetVehicle(int id)
97 91 { {
98 var vehicle = await context.Vehicles
99 .Include(v => v.Features)
100 .ThenInclude(vf => vf.Feature)
101 .Include(v => v.Model)
102 .ThenInclude(m => m.Make)
103 .SingleOrDefaultAsync(v => v.Id == id);
92 var vehicle = await repository.GetVehicle(id);
104 93
105 94 if (vehicle == null) if (vehicle == null)
106 95 return NotFound(); return NotFound();
File Core/Repositories/IVehicleRepository.cs added (mode: 100644) (index 0000000..87ee5d7)
1 using System.Threading.Tasks;
2 using vega.Models;
3 using vega.Persistence;
4
5 namespace vega.Core.Repositories
6 {
7 public interface IVehicleRepository
8 {
9 Task<Vehicle> GetVehicle(int id);
10 }
11 }
File Persistence/Repositories/VehicleRepository.cs added (mode: 100644) (index 0000000..77173b0)
1 using System.Threading.Tasks;
2 using Microsoft.EntityFrameworkCore;
3 using vega.Core.Repositories;
4 using vega.Models;
5
6 namespace vega.Persistence.Repositories
7 {
8 public class VehicleRepository : IVehicleRepository
9 {
10 private readonly VegaDbContext context;
11 public VehicleRepository(VegaDbContext context)
12 {
13 this.context = context;
14 }
15 public async Task<Vehicle> GetVehicle(int id)
16 {
17 return await context.Vehicles
18 .Include(v => v.Features)
19 .ThenInclude(vf => vf.Feature)
20 .Include(v => v.Model)
21 .ThenInclude(m => m.Make)
22 .SingleOrDefaultAsync(v => v.Id == id);
23 }
24 }
25 }
File Startup.cs changed (mode: 100644) (index 9433e33..175d242)
... ... using Microsoft.Extensions.DependencyInjection;
8 8 using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
9 9 using vega.Persistence; using vega.Persistence;
10 10 using AutoMapper; using AutoMapper;
11 using vega.Persistence.Repositories;
12 using vega.Core.Repositories;
11 13
12 14 namespace vega namespace vega
13 15 { {
 
... ... namespace vega
23 25 // This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
24 26 public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
25 27 { {
28 services.AddScoped<IVehicleRepository, VehicleRepository>();
29
26 30 services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
27 31
28 32 services.AddDbContext<VegaDbContext>(options => services.AddDbContext<VegaDbContext>(options =>
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/antcalatayud/vega

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/antcalatayud/vega

Clone this repository using git:
git clone git://git.rocketgit.com/user/antcalatayud/vega

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main