Ejemplo n.º 1
0
 public async Task <IHttpActionResult> CreateVehicleMakeAsync(VehicleMakeVM vehicleMake)
 {
     if (ModelState.IsValid)
     {
         await _vehicleMakeService.AddVehicleMakeAsync(Mapper.Map <VehicleMake>(vehicleMake));
     }
     return(Ok(vehicleMake));
 }
Ejemplo n.º 2
0
        public async Task <HttpResponseMessage> PostAsync([FromQuery] QueryParams queryParams)
        {
            var vehicleMake = mapper.Map <IVehicleMakeDTO>(queryParams);

            vehicleMake.Id = Guid.NewGuid();

            await vehicleMakeService.AddVehicleMakeAsync(vehicleMake);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Ejemplo n.º 3
0
        public async Task <IHttpActionResult> Post([FromBody] VehicleMakeVM VM)
        {
            try
            {
                await service.AddVehicleMakeAsync(AutoMapper.Mapper.Map <VehicleMake>(VM));

                return(Ok());
            }
            catch (DataException)
            {
                ModelState.AddModelError("", "Something went wrong with creating VehicleMake");
                return(InternalServerError());
            }
        }
Ejemplo n.º 4
0
 public async Task <IActionResult> AddVehicleMakeAsync(VehicleMakeViewModel vehicleMakeViewModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var vehicleMake = mapper.Map <IVehicleMakeDTO>(vehicleMakeViewModel);
             vehicleMake.Id = Guid.NewGuid();
             await vehicleMakeService.AddVehicleMakeAsync(vehicleMake);
         }
         else
         {
             return(RedirectToAction(nameof(AddVehicleMake)));
         }
         return(RedirectToAction(nameof(GetVehicleMakeAsync)));
     }
     catch
     {
         return(View());
     }
 }