public ActionResult Edit([Bind(Include = "Id,Filled,FullName,TimeDeliver,ClientAddress,TotalCost")] DbDeliveryRquest dbDeliveryRquest) { if (ModelState.IsValid) { db.Entry(dbDeliveryRquest).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dbDeliveryRquest)); }
public ActionResult Create([Bind(Include = "Id,Filled,FullName,TimeDeliver,ClientAddress,TotalCost")] DbDeliveryRquest dbDeliveryRquest) { if (ModelState.IsValid) { db.DeliveryRequest.Add(dbDeliveryRquest); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dbDeliveryRquest)); }
// GET: DbDeliveryRquests/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DbDeliveryRquest dbDeliveryRquest = db.DeliveryRequest.Find(id); if (dbDeliveryRquest == null) { return(HttpNotFound()); } return(View(dbDeliveryRquest)); }
public ActionResult Print(HttpPostedFileBase file) { if (file != null && file.ContentLength > 0) { var dto = DeliverySerializer.LoadFromStream(file.InputStream); Dictionary <string, int> titleArray = new Dictionary <string, int>(); using (var db = new ApplicationDbContext()) { var row = new DbDeliveryRquest { ClientAddress = dto.ClientAddress, Filled = dto.Filled, TimeDeliver = dto.TimeDeliver, TotalCost = dto.TotalCost, FullName = dto.FullName }; row.WayPoints = new Collection <DbWayPoint>(); foreach (var wpDto in dto.WayPoints) { var wp = new DbWayPoint { Address = wpDto.Address, PlaceTitle = wpDto.PlaceTitle, ShopType = wpDto.ShopType, }; row.WayPoints.Add(wp); wp.ProductsList = new Collection <DbProduct>(); foreach (var product in wpDto.ProductsList) { var p = new DbProduct { Name = product.Name, Amount = product.Amount, Additions = product.Additions, Cost = product.Cost, }; wp.ProductsList.Add(p); } db.productList.AddRange(wp.ProductsList); } db.DeliveryRequest.Add(row); db.SaveChanges(); return(View(dto)); } } return(RedirectToAction("Index")); }