public bool UpdateOrderCandidateByStoreProduct(List <OrderCandidateEL> orderCandidateELList) { bool isOrderCandidatePriceUpdated = false; try { List <OrderCandidate> lstOrders = new List <OrderCandidate>(); double subtotal = 0.00; int orderRecieptID = 0; using (uow = new UnitOfWork.UnitOfWork()) { foreach (OrderCandidateEL orderCandidateEL in orderCandidateELList) { OrderCandidate orderCandidate = uow.OrderCandidateRepository.Get().Where(x => x.StoreID == orderCandidateEL.StoreID && x.ProductID == orderCandidateEL.ProductID).FirstOrDefault(); orderCandidate.Price = orderCandidateEL.Price; orderCandidate.IsAvailable = orderCandidateEL.IsAvailable; orderCandidate.UpdatedOn = DateTime.Now.ToString(); subtotal = subtotal + Convert.ToDouble(orderCandidateEL.Price); orderRecieptID = Convert.ToInt32(orderCandidate.RecieptOrderID); lstOrders.Add(orderCandidate); } uow.OrderCandidateRepository.UpdateBulk(lstOrders); isOrderCandidatePriceUpdated = true; } using (uow = new UnitOfWork.UnitOfWork()) { RecieptOrder recOrder = uow.RecieptOrderRepository.Get().Where(x => x.RecieptOrderID == orderRecieptID).FirstOrDefault(); if (recOrder != null) { recOrder.Subtotal = subtotal.ToString(); uow.RecieptOrderRepository.Update(recOrder); uow.Save(); RecieptEL recEL = new RecieptEL(); recEL.Status = ((int)ReceiptStatus.Quoted).ToString(); recEL.RecieptID = Convert.ToInt32(recOrder.RecieptID); recHelper.UpdateOrderReceipt(recEL); } } } catch { } return(isOrderCandidatePriceUpdated); }
public bool AddOrderCandidate(OrderCandidateEL orderCandidateEL) { bool isOrderCandidateAdded = false; try { OrderCandidate orderCandidate = new OrderCandidate(); orderCandidate = MapperUtility.MapTo(orderCandidateEL, orderCandidate); using (uow = new UnitOfWork.UnitOfWork()) { uow.OrderCandidateRepository.Insert(orderCandidate); uow.Save(); isOrderCandidateAdded = true; } } catch { } return(isOrderCandidateAdded); }
public bool AddOrderReceipt(ReceiptOrderEL receiptOrderEL) { bool isOrderReceiptAdded = false; try { RecieptOrder recieptOrder = new RecieptOrder(); recieptOrder = MapperUtility.MapTo(receiptOrderEL, recieptOrder); using (uow = new UnitOfWork.UnitOfWork()) { uow.RecieptOrderRepository.Insert(recieptOrder); uow.Save(); isOrderReceiptAdded = true; int orderRecieptID = recieptOrder.RecieptOrderID; List <Product> lstProduct = uow.ProductRepository.Get().Where(x => x.RecieptID == receiptOrderEL.RecieptID).ToList(); List <OrderCandidate> lstOrderCandidate = new List <OrderCandidate>(); foreach (Product product in lstProduct) { OrderCandidate orderCandidate = new OrderCandidate(); orderCandidate.CreatedOn = DateTime.Now.ToString(); orderCandidate.IsAvailable = false; orderCandidate.Price = "0.00"; orderCandidate.ProductID = product.ProductID; orderCandidate.StoreID = receiptOrderEL.ReceiverStoreID; orderCandidate.UpdatedOn = null; orderCandidate.RecieptOrderID = orderRecieptID; lstOrderCandidate.Add(orderCandidate); } uow.OrderCandidateRepository.InsertBulk(lstOrderCandidate); uow.Save(); } } catch { isOrderReceiptAdded = false; } return(isOrderReceiptAdded); }