public ActionResult Create(EventsModelInput model) { try { var eventsDto = GenerateDto(model); var res = _manager.AddEvents(eventsDto); return(Json(new ResultModel { Error = res ? string.Empty : "Error during the save in db!" })); } catch (Exception ex) { return(Json(new ResultModel { Error = "Error during the save process!" })); } }
private EventsDto GenerateDto(EventsModelInput model) { var eventsDto = new EventsDto { Title = model.Title, Author = User.Identity.Name, Description = model.Description, ShortDescription = model.ShortDescription, }; if (model.ImageFile != null) { eventsDto.Image = new ImageDto { Blob = Base64Manager.ReadFully(model.ImageFile.InputStream), MimeType = model.ImageFile.ContentType, FileName = model.ImageFile.FileName, Size = model.ImageFile.ContentLength } } ; return(eventsDto); } }