public ActionResult EditPallet(int palletId) { var packingDataService = new PackingDataService(); var pallet = packingDataService.GetPalletById(palletId); return(PartialView(new PalletViewModel(pallet))); }
public ActionResult PackProduct() { var packingDataService = new PackingDataService(); var allPallets = packingDataService.GetAllPallets(); ViewBag.Pallets = allPallets.Select(x => new PalletViewModel(x)).ToList(); return(PartialView()); }
public ActionResult EditPallet(PalletViewModel pallet) { var packingDataService = new PackingDataService(); var result = packingDataService.UpdatePallet(pallet); if (result) { return(Json(new AjaxResult("Palet başarıyla kaydedildi."))); } return(Json(new AjaxResult("Palet kaydedilemedi!"))); }
public ActionResult DeletePallet(int palletId) { var result = new PackingDataService().DeletePalletById(palletId); return(new JsonResult() { Data = result, ContentType = "application/json", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult ListPallets() { var allPallets = new PackingDataService().GetAllPallets(); var orderedPallets = allPallets.OrderBy(x => x.Id); var allPalletsForView = orderedPallets.Select(x => new PalletViewModel(x)); return(new JsonResult() { Data = allPalletsForView, ContentType = "application/json", JsonRequestBehavior = JsonRequestBehavior.AllowGet, MaxJsonLength = Int32.MaxValue }); }
public ActionResult EditOrderPacking(int orderId) { var salesDataService = new SalesDataService(); var packingDataService = new PackingDataService(); var order = salesDataService.GetSalesById(orderId); var packedProducts = packingDataService.GetPackedProductsByOrderId(orderId); var packing = new PackingViewModel { OrderId = orderId, Pallets = new List <PackingViewModel.PackingPallet>() }; foreach (var packedProduct in packedProducts) { var packedPrdct = new PackingViewModel.PackingPallet.PackedProduct { ProductCode = packedProduct.ProductCode, Quantity = packedProduct.Quantity }; var palletOfProduct = packing.Pallets.FirstOrDefault(x => x.PalletId == packedProduct.PalletId); if (palletOfProduct != null) { palletOfProduct.Products.Add(packedPrdct); } else { palletOfProduct = new PackingViewModel.PackingPallet { PalletId = packedProduct.PalletId, Products = new List <PackingViewModel.PackingPallet.PackedProduct>() }; palletOfProduct.Products.Add(packedPrdct); packing.Pallets.Add(palletOfProduct); } } ViewBag.Order = new OrderViewModel(order); ViewBag.Packing = packing; return(PartialView()); }
public ActionResult UpdatePacking(PackingViewModel packingDetail) { var packingDataService = new PackingDataService(); packingDataService.DeletePackedProductsByOrderId(packingDetail.OrderId); foreach (var packingDetailPallet in packingDetail.Pallets) { foreach (var packedProduct in packingDetailPallet.Products) { packingDataService.CreatePackedProduct(new PackedProduct { OrderId = packingDetail.OrderId, PalletId = packingDetailPallet.PalletId, ProductCode = packedProduct.ProductCode, Quantity = packedProduct.Quantity }); } } return(Json(new AjaxResult(true))); }
public ActionResult GetPackedProductsExportInfo(int orderId) { var packingExportInfo = new PackingDataService().GetPackingExportInfo(orderId); var groups = packingExportInfo.GroupBy(x => x.PalletId).ToList(); foreach (var packing in groups) { foreach (var productExport in packing.Skip(1)) { productExport.PalletId = string.Empty; productExport.Dimensions = string.Empty; productExport.NetKG = string.Empty; productExport.GrossKG = string.Empty; } } var filteredEmptyRows = packingExportInfo.Where(x => !string.IsNullOrEmpty(x.PalletId)).ToList(); var lastRow = new PackedProductExport { PalletId = "TOPLAM", Quantity = packingExportInfo.Sum(x => Convert.ToInt32(x.Quantity)).ToString(), NetKG = filteredEmptyRows.Sum(x => Convert.ToDouble(x.NetKG)).ToString(), GrossKG = filteredEmptyRows.Sum(x => Convert.ToDouble(x.GrossKG)).ToString(), ProductCode = string.Empty, Description = string.Empty, Dimensions = string.Empty }; packingExportInfo.Add(lastRow); return(new JsonResult() { Data = packingExportInfo, ContentType = "application/json", JsonRequestBehavior = JsonRequestBehavior.AllowGet, MaxJsonLength = Int32.MaxValue }); }
public ActionResult CreatePacking(PackingViewModel packingDetail) { var packingDataService = new PackingDataService(); foreach (var packingDetailPallet in packingDetail.Pallets) { foreach (var packedProduct in packingDetailPallet.Products) { packingDataService.CreatePackedProduct(new PackedProduct { OrderId = packingDetail.OrderId, PalletId = packingDetailPallet.PalletId, ProductCode = packedProduct.ProductCode, Quantity = packedProduct.Quantity }); } } var salesDataService = new SalesDataService(); salesDataService.UpdateOrderState(packingDetail.OrderId, SalesState.PackingIsReady); return(Json(new AjaxResult(true))); }