public ActionResult Add(InquiryBag bag) { InquiryItem item = new InquiryItem() { Id = Guid.NewGuid(), Amount = bag.Amount, Comments = bag.Comments, HDPEPrice = bag.HDPEPrice, InquiryId = bag.InquiryId, IsSuccessful = bag.IsSuccessful, NominalWeightPerMeter = bag.NominalWeightPerMeter, PricePerKilo = Math.Ceiling((bag.Amount * bag.PricePerUnit) / bag.TotalWeight), PricePerUnit = bag.PricePerUnit, TotalWeight = bag.TotalWeight, ProductId = bag.ProductId, ReasonForFailure = bag.ReasonForFailure, WasherPrice = bag.WasherPrice, TotalPrice = (bag.Amount * bag.PricePerUnit) }; context.InquiryItems.Add(item); context.SaveChanges(); ViewBag.ModelOperatedId = item.Id; return(RedirectToAction("Index", new { area = "commerce", controller = "Inquiries" })); }
public ActionResult Add(Guid inquiryId) { Inquiry inquiry = context.Inquiries.Include("Customer").Where(i => i.Id.Equals(inquiryId)).FirstOrDefault(); InquiryBag bag = new InquiryBag { InquiryId = inquiry.Id, CustomerId = inquiry.CustomerId, CustomerName = inquiry.Customer.Name, CustomerTel = inquiry.Customer.InquiryTel, CustomerAddress = inquiry.Customer.InquiryAddress }; return(View("~/Areas/Commerce/Views/InquiriesRelated/Inquiries/Add.cshtml", bag)); }
public ActionResult Edit(Guid id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InquiryItem inquiryItem = context.InquiryItems.Include("Product").Include("Inquiry.Customer").Where(i => i.Id.Equals(id)).FirstOrDefault(); InquiryBag inquiryBag = null; if (inquiryItem != null) { inquiryBag = ConvertInquiryItemToInquiryBag(inquiryItem); } return(View("~/Areas/Commerce/Views/InquiriesRelated/Inquiries/Edit.cshtml", inquiryBag)); }
public ActionResult Edit(InquiryBag bag) { InquiryItem inquiryItem = context.InquiryItems.Find(bag.Id); inquiryItem.IsSuccessful = bag.IsSuccessful; inquiryItem.ProductId = bag.ProductId; inquiryItem.Amount = bag.Amount; inquiryItem.Comments = bag.Comments; inquiryItem.HDPEPrice = bag.HDPEPrice; inquiryItem.IsSuccessful = bag.IsSuccessful; inquiryItem.NominalWeightPerMeter = bag.NominalWeightPerMeter; inquiryItem.PricePerUnit = bag.PricePerUnit; inquiryItem.ReasonForFailure = bag.ReasonForFailure; inquiryItem.TotalPrice = bag.Amount * bag.PricePerUnit; inquiryItem.PricePerKilo = Math.Ceiling(inquiryItem.TotalPrice / bag.TotalWeight); inquiryItem.WasherPrice = bag.WasherPrice; context.Entry(inquiryItem).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); ViewBag.ModelOperatedId = inquiryItem.Id.ToString(); return(RedirectToAction("Index", new { area = "commerce", controller = "Inquiries" })); }