示例#1
0
        public ActionResult Modify(VehicleViewModel model)
        {
            if (ModelState.IsValid)
            {
                var dbModel = Mapper.Map <VehicleViewModel, VehicleModel>(model);
                if (model.Id > 0) // Edit
                {
                    _vehicleBusiness.Edit(dbModel);

                    return(RedirectToAction("Edit", "Vehicle", new { area = "AdminPanel", id = dbModel.Id, isSuccessModified = true }));
                }
                else // Add
                {
                    var vehicleId = _vehicleBusiness.Add(dbModel);
                    return(RedirectToAction("Index", "VehicleImage", new { area = "AdminPanel", vehicleId = vehicleId }));
                }
            }

            return(View("Modify", model));
        }
示例#2
0
 public ActionResult<Vehicle> Create([FromBody]Vehicle vehicle)
 {
     _vehicleBusiness.Add(vehicle);
     return CreatedAtAction(nameof(GetVehicle), new { vehicle.Id }, vehicle);
 }