Esempio n. 1
0
 public ActionResult Edit(EditVehicleViewModel model)
 {
     if (ModelState.IsValid)
     {
         _logics.SubmitEdit(model);
         SuccessMessage("Автомобиль успешно изменен");
         return RedirectToAction("Index");
     }
     ErrorMessage("При изменении автомобиля произошла ошибка");
     return View(model);
 }
Esempio n. 2
0
        public void SubmitEdit(EditVehicleViewModel model)
        {
            var eventInfo = new LogEventInfo(LogLevel.Info, _logger.Name, "Vehicle edit");
            eventInfo.Properties["ModelName"] = model.Name;

            var vehicleDto = Mapper.Map<VehicleDTO>(model);
            if (model.Photo == null)
                vehicleDto.Photo = _vehicleService.GetVehicleInfo(model.Id).Photo;
            else
                vehicleDto.Photo = new ImageDTO
                {
                    Type = model.Photo.ContentType,
                    Bytes = model.Photo.InputStream.ReadBytes(model.Photo.ContentLength)
                };
            var result = _vehicleService.ModifyVehicle(vehicleDto);

            if (result.Status == ServiceResultStatus.Success)
                _logger.Info(eventInfo);
            else _logger.Error(eventInfo);
        }