public ActionResult SetItemQuantity(int id, decimal value) { var entity = DeliveryOrderDetail.Find(id); var product = entity.Product; if (entity.DeliveryOrder.IsCompleted || entity.DeliveryOrder.IsCancelled) { Response.StatusCode = 400; return(Content(Resources.ItemAlreadyCompletedOrCancelled)); } if (value >= 0 && value <= GetRemainQuantityBySalesOrderDetail(entity.OrderDetail)) { entity.Quantity = value; } else { entity.Quantity = GetRemainQuantityBySalesOrderDetail(entity.OrderDetail); } using (var scope = new TransactionScope()) { entity.UpdateAndFlush(); } return(Json(new { id = entity.Id, value = entity.FormattedValueFor(x => x.Quantity) })); }
public ActionResult SetItemProductName(int id, string value) { var entity = DeliveryOrderDetail.Find(id); string val = (value ?? string.Empty).Trim(); if (entity.DeliveryOrder.IsCompleted || entity.DeliveryOrder.IsCancelled) { Response.StatusCode = 400; return(Content(Resources.ItemAlreadyCompletedOrCancelled)); } if (val.Length == 0) { entity.ProductName = entity.Product.Name; } else { entity.ProductName = val; } using (var scope = new TransactionScope()) { entity.UpdateAndFlush(); } return(Json(new { id = entity.Id, value = entity.ProductName })); }
public ActionResult RemoveItem(int id) { var entity = DeliveryOrderDetail.Find(id); if (entity.DeliveryOrder.IsCompleted || entity.DeliveryOrder.IsCancelled) { Response.StatusCode = 400; return(Content(Resources.ItemAlreadyCompletedOrCancelled)); } using (var scope = new TransactionScope()) { entity.DeleteAndFlush(); } return(Json(new { id = id, result = true })); }
public ActionResult Item(int id) { var item = DeliveryOrderDetail.Find(id); return(PartialView("_ItemEditorView", item)); }