Exemple #1
0
        // POST: api/Makes
        public HttpResponseMessage Post([FromBody] VehicleMake vehicle)
        {
            var mappedVehicle = Mapper.Map <VehicleApp.Repository.Models.VehicleMake>(vehicle);

            service.CreateVehicleMake(mappedVehicle);

            return(Request.CreateResponse(HttpStatusCode.Created, vehicle));
        }
        public async Task <ActionResult> Create([Bind(Include = "Name, Abbreviation")] VehicleMake vehicleMakeToInsert)
        {
            if (!await _vehicleMakeService.CreateVehicleMake(vehicleMakeToInsert))
            {
                return(View(_mapper.Map <VehicleMakeViewModel>(vehicleMakeToInsert)));
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Create([Bind(Include = "Id, Name, Abrv")] VehicleMakeModelView make)
        {
            //make.Id = Guid.NewGuid();

            if (ModelState.IsValid)
            {
                service.CreateVehicleMake(Mapper.Map <VehicleMake>(make));
                return(RedirectToAction("Index"));
            }
            return(View());
        }
Exemple #4
0
        public async Task <IHttpActionResult> CreateVehicleMake(VehicleMakeViewModel vehicleMakeViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            VehicleMake vehicleMake = iMapper.Map <VehicleMake>(vehicleMakeViewModel);
            await _vehicleService.CreateVehicleMake(vehicleMake);

            return(CreatedAtRoute("DefaultApi", new { id = vehicleMakeViewModel.MakeId }, vehicleMakeViewModel));
        }
Exemple #5
0
 public ActionResult Create(CreateVehicleMakeViewModel viewModel)
 {
     if (!ModelState.IsValid)
     {
         return(View(viewModel));
     }
     else
     {
         VehicleMake model = AutoMapper.Mapper.Map <CreateVehicleMakeViewModel, VehicleMake>(viewModel);
         service.CreateVehicleMake(model);
         return(RedirectToAction("Index"));
     }
 }
Exemple #6
0
        public async Task <ActionResult <ReadVehicleMake> > CreateMake(CreateParams makeToCreateParams)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var makeToCreate       = mapper.Map <VehicleMake>(makeToCreateParams);
            var createdVehicleMake = await service.CreateVehicleMake(makeToCreate);

            var createdVehicleMakeRestModel = mapper.Map <ReadVehicleMake>(createdVehicleMake);

            return(Created($"api/makes/{createdVehicleMakeRestModel.Id}", createdVehicleMakeRestModel));
        }