public IHttpActionResult GetCustomerPODetail() { try { List <CustomerPurchaseOrderDetailAC> listOfCustomerPurchaseOrderDetailAC = new List <CustomerPurchaseOrderDetailAC>(); List <CustomerPurchaseOrder> listOfCustomerPurchaseOrder = _customerPOWorkListContext.GetListOfCustomerPurchaseOrderByBranch(Convert.ToInt32(MerchantContext.UserDetails.BranchId)); foreach (var item in listOfCustomerPurchaseOrder) { CustomerPurchaseOrderDetailAC customerPurchaseOrderDetailAc = new CustomerPurchaseOrderDetailAC(); customerPurchaseOrderDetailAc.CustomerName = item.CustomerProfile.Name; customerPurchaseOrderDetailAc.Id = item.Id; customerPurchaseOrderDetailAc.IssueDate = item.InitiationDate; customerPurchaseOrderDetailAc.CollectionBranch = item.CollectingBranch.Name; customerPurchaseOrderDetailAc.CollectionDate = item.CollectionDate; customerPurchaseOrderDetailAc.MemberShipCode = item.CustomerProfile.MembershipCode; customerPurchaseOrderDetailAc.OrderNumber = item.PurchaseOrderNo; List <CustomerPurchaseOrderItemAC> listOfCustomerPurchaseOrderItem = new List <CustomerPurchaseOrderItemAC>(); List <CPOBill> cpoBillList = _customerPOWorkListContext.GetCPOBillListByPOId(customerPurchaseOrderDetailAc.Id); foreach (var cpoBill in cpoBillList) { List <POSBillItem> listOfPOSBillItem = _customerPOWorkListContext.getPOsBillItemByBillId(cpoBill.POSBillId); foreach (var posBillItem in listOfPOSBillItem) { CustomerPurchaseOrderItemAC customerPurchaseOrderItemAC = new CustomerPurchaseOrderItemAC(); customerPurchaseOrderItemAC.Barcode = posBillItem.ItemProfile.Barcode; customerPurchaseOrderItemAC.ItemName = posBillItem.ItemProfile.ItemNameEn; customerPurchaseOrderItemAC.Price = posBillItem.SellPrice; customerPurchaseOrderItemAC.Quantity = posBillItem.Quantity; listOfCustomerPurchaseOrderItem.Add(customerPurchaseOrderItemAC); } } customerPurchaseOrderDetailAc.CustomerPurchaseOrderItemList = listOfCustomerPurchaseOrderItem; if (customerPurchaseOrderDetailAc.CustomerPurchaseOrderItemList.Count > 0) { customerPurchaseOrderDetailAc.HasChildItem = true; } listOfCustomerPurchaseOrderDetailAC.Add(customerPurchaseOrderDetailAc); } return(Ok(listOfCustomerPurchaseOrderDetailAC)); } catch (Exception ex) { _errorLog.LogException(ex); throw; } }
public IHttpActionResult GetCustomerPO(int id) { try { if (HttpContext.Current.User.Identity.IsAuthenticated) { var customerPO = _customerPOWorkListContext.GetCustomerPO(id); List <CustomerPurchaseOrderItemAC> listOfCustomerPurchaseOrderItem = new List <CustomerPurchaseOrderItemAC>(); List <CPOBill> cpoBillList = _customerPOWorkListContext.GetCPOBillListByPOId(id); foreach (var cpoBill in cpoBillList) { List <POSBillItem> listOfPOSBillItem = _customerPOWorkListContext.getPOsBillItemByBillId(cpoBill.POSBillId); foreach (var posBillItem in listOfPOSBillItem) { CustomerPurchaseOrderItemAC customerPurchaseOrderItemAC = new CustomerPurchaseOrderItemAC(); customerPurchaseOrderItemAC.Barcode = posBillItem.ItemProfile.Barcode; customerPurchaseOrderItemAC.ItemName = posBillItem.ItemProfile.ItemNameEn; customerPurchaseOrderItemAC.Price = posBillItem.SellPrice; customerPurchaseOrderItemAC.Quantity = posBillItem.Quantity; listOfCustomerPurchaseOrderItem.Add(customerPurchaseOrderItemAC); } } List <CPOItemAC> listOfCPOItem = new List <CPOItemAC>(); foreach (var item in customerPO.CPOItem) { CPOItemAC cpoItemAC = new CPOItemAC(); cpoItemAC.ItemName = item.ItemProfile.ItemNameEn; cpoItemAC.Flavour = item.ItemProfile.FlavourEn; cpoItemAC.ItemTotalCost = item.ItemTotalCost; cpoItemAC.OfferSellPrice = item.OfferSellPrice; cpoItemAC.OrderedOfferQuantity = item.OrderedOfferQuantity; cpoItemAC.Quantity = item.Quantity; cpoItemAC.SellPrice = item.SellPrice; cpoItemAC.Unit = item.ItemProfile.SystemParameter.ValueEn; cpoItemAC.Barcode = item.Barcode; var cpoItem = listOfCustomerPurchaseOrderItem.FirstOrDefault(x => x.Barcode == item.Barcode); if (cpoItem == null) { cpoItemAC.Status = "Not Collected"; } else { if (cpoItem.Quantity >= cpoItemAC.Quantity) { cpoItemAC.Status = "Collected"; } else { cpoItemAC.Status = "Partial Collected"; } } listOfCPOItem.Add(cpoItemAC); } customerPO.CPOItemAC = listOfCPOItem; customerPO.listOfCustomerPurchaseOrderItem = listOfCustomerPurchaseOrderItem; return(Ok(customerPO)); } else { return(BadRequest()); } } catch (Exception ex) { _errorLog.LogException(ex); throw; } }