public ActionResult Update(int id) { FullVapeDTO fullVapeDto = orderService.GetFullVape(id); Mapper.Initialize(cfg => cfg.CreateMap <FullVapeDTO, FullVapeViewModel>()); var fullvape = Mapper.Map <FullVapeDTO, FullVapeViewModel>(fullVapeDto); return(View(fullvape)); }
public ActionResult MakeOrderFullVape(int?id) { try { FullVapeDTO fullVape = orderService.GetFullVape(id); Mapper.Initialize(cfg => cfg.CreateMap <FullVapeDTO, OrderViewModel>() .ForMember("FullVapeId", opt => opt.MapFrom(src => src.Id))); var order = Mapper.Map <FullVapeDTO, OrderViewModel>(fullVape); return(View(order)); } catch (ValidationException ex) { return(Content(ex.Message)); } }
public void AddFullVape(FullVapeDTO fullVapeDto) { FullVape fullVape = new FullVape { Name = fullVapeDto.Name, Company = fullVapeDto.Company, Accumulator = fullVapeDto.Accumulator, Brand = fullVapeDto.Brand, Amount = fullVapeDto.Amount, Contry = fullVapeDto.Contry, Outturn = fullVapeDto.Outturn, Price = fullVapeDto.Price, }; Database.FullVapes.Create(fullVape); Database.Save(); }
public ActionResult Upload(HttpPostedFileBase uploadImage, int id) { FullVapeDTO fullVapeDto = imageService.GetFullVape(id);//? if (ModelState.IsValid && fullVapeDto != null) { ImageDTO image = new ImageDTO { FullVapeId = id, MimeType = uploadImage.ContentType, }; image.Data = new byte[uploadImage.ContentLength]; uploadImage.InputStream.Read(image.Data, 0, uploadImage.ContentLength); imageService.Add(image); return(View("View")); } else { return(View("View1")); } }
public ActionResult Add(FullVapeViewModel fullVapeViewModel) { if (ModelState.IsValid) { FullVapeDTO fullVapeDto = new FullVapeDTO { Name = fullVapeViewModel.Name, Company = fullVapeViewModel.Company, Accumulator = fullVapeViewModel.Accumulator, Brand = fullVapeViewModel.Brand, Amount = fullVapeViewModel.Amount, Contry = fullVapeViewModel.Contry, Outturn = fullVapeViewModel.Outturn, Price = fullVapeViewModel.Price, }; orderService.AddFullVape(fullVapeDto); return(View("View")); } else { return(View("View1")); } }