public async Task Build() { var data = await _dtoStore.GetFirstLine(); var properties = data.Split(); var parseSuccessful = ParseValues.ParseFromStringToInt(properties[1], out int capacity); if (parseSuccessful) { var bag = new Bag(capacity); _bagRepository.AddBag(bag); } else { throw new Exception("Bag Data is incorrect"); } }
public ActionResult Create(Bag bag) { if (ModelState.IsValid) { List <Picture> BagsPictures = new List <Picture>(); if (bag.files.Length > 0) { foreach (HttpPostedFileBase file in bag.files) { if (file != null) { BagsPictures.Add(FileUpload(file)); } else { Picture Fd = new Picture(); Fd.FileName = "default"; Fd.Extension = "png"; System.Drawing.Image defaultImage = System.Drawing.Image.FromFile(Server.MapPath("~/Images/default.png")); using (MemoryStream ms = new MemoryStream()) { defaultImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); Fd.FileContent = ms.ToArray(); } BagsPictures.Add(Fd); } } } bag.BagsPictures = BagsPictures; bagRepo.AddBag(bag); return(RedirectToAction("Index")); } else { bag.ColorList = bagRepo.GetColors().ToList(); bag.CategoryList = bagRepo.GetCategories(); } return(View(bag)); }