Esempio n. 1
0
        public AddOrderRecieptResponse AddOrderReciept(AddOrderRecieptRequest request)
        {
            AddOrderRecieptResponse addOrderRecieptResponse = new AddOrderRecieptResponse();

            addOrderRecieptResponse.Message = "Reciept order not added successfully.";

            if (String.IsNullOrEmpty(request.AuthToken))
            {
                addOrderRecieptResponse.Message = "Please pass all mandatory fields.";
                return(addOrderRecieptResponse);
            }

            AuthenticationToken authToken = new Helper().GetAuthenticationToken(request.AuthToken);

            if (authToken == null)
            {
                addOrderRecieptResponse.Message = "Unauthorizes user.";
                return(addOrderRecieptResponse);
            }

            if (request.ReceiverStoreID == 0 || request.RecieptID == 0)
            {
                addOrderRecieptResponse.Message = "Please pass all values.";
                return(addOrderRecieptResponse);
            }

            ReceiptOrderEL recieptOrderEL = new ReceiptOrderEL();

            request.SenderStoreID = Convert.ToInt32(authToken.FkUserID);
            recieptOrderEL        = MapperUtility.MapTo(request, recieptOrderEL);

            if (orderReceiptHelper.IsOrderRecieptAvailable(recieptOrderEL))
            {
                addOrderRecieptResponse.Message = "This reciept already sent to this store.";
                return(addOrderRecieptResponse);
            }

            if (orderReceiptHelper.AddOrderReceipt(recieptOrderEL))
            {
                addOrderRecieptResponse.Message   = "Reciept order added successfully.";
                addOrderRecieptResponse.IsSuccess = true;
                RecieptEL recEL = new RecieptEL();

                recEL.Price     = "0.00";
                recEL.Status    = ((int)ReceiptStatus.ProcessedToVendor).ToString();
                recEL.RecieptID = request.RecieptID;
                receiptHelper.UpdateOrderReceipt(recEL);
                return(addOrderRecieptResponse);
            }
            else
            {
                addOrderRecieptResponse.Message = "Some error occured.";
                return(addOrderRecieptResponse);
            }
        }
        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);
        }
Esempio n. 3
0
        public AddRecieptResponse AddReciept(AddRecieptRequest request)
        {
            AddRecieptResponse addRecieptResponse = new AddRecieptResponse();

            addRecieptResponse.Message = "Reciept not added successfully.";

            if (String.IsNullOrEmpty(request.AuthToken))
            {
                addRecieptResponse.Message = "Please pass all mandatory fields.";
                return(addRecieptResponse);
            }

            AuthenticationToken authToken = new Helper().GetAuthenticationToken(request.AuthToken);

            if (authToken == null)
            {
                addRecieptResponse.Message = "Unauthorizes user.";
                return(addRecieptResponse);
            }

            if (String.IsNullOrEmpty(request.recieptDTO.Name))
            {
                addRecieptResponse.Message = "Please pass reciept name.";
                return(addRecieptResponse);
            }

            RecieptEL recieptEL = new RecieptEL();

            recieptEL = MapperUtility.MapTo(request.recieptDTO, recieptEL);
            if (receiptHelper.AddReceipt(recieptEL))
            {
                addRecieptResponse.Message   = "Reciept added successfully.";
                addRecieptResponse.IsSuccess = true;
                return(addRecieptResponse);
            }
            else
            {
                addRecieptResponse.Message = "Some error occured.";
                return(addRecieptResponse);
            }
        }
        public bool EditReceipt(RecieptEL recieptEL)
        {
            bool isRecieptEdited = false;

            try
            {
                using (uow = new UnitOfWork.UnitOfWork())
                {
                    Reciept reciept = uow.RecieptRepository.GetById(recieptEL.RecieptID);
                    reciept = MapperUtility.MapTo(recieptEL, reciept);
                    uow.RecieptRepository.Update(reciept);
                    uow.Save();
                    isRecieptEdited = true;
                }
            }
            catch
            {
                isRecieptEdited = false;
            }

            return(isRecieptEdited);
        }
        public bool AddReceipt(RecieptEL recieptEL)
        {
            bool isRecieptAdded = false;

            try
            {
                Reciept reciept = new Reciept();
                reciept = MapperUtility.MapTo(recieptEL, reciept);
                using (uow = new UnitOfWork.UnitOfWork())
                {
                    uow.RecieptRepository.Insert(reciept);
                    uow.Save();
                    isRecieptAdded = true;
                }
            }
            catch
            {
                isRecieptAdded = false;
            }

            return(isRecieptAdded);
        }
        public bool UpdateOrderReceipt(RecieptEL recieptEL)
        {
            bool isRecieptEdited = false;

            try
            {
                using (uow = new UnitOfWork.UnitOfWork())
                {
                    Reciept reciept = uow.RecieptRepository.GetById(recieptEL.RecieptID);
                    reciept.Status = recieptEL.Status;
                    reciept.Price  = recieptEL.Price;
                    uow.RecieptRepository.Update(reciept);
                    uow.Save();
                    isRecieptEdited = true;
                }
            }
            catch
            {
                isRecieptEdited = false;
            }

            return(isRecieptEdited);
        }
Esempio n. 7
0
        public AddRecieptResponse UpdateRecieptStatus(AddRecieptRequest request)
        {
            AddRecieptResponse addRecieptResponse = new AddRecieptResponse();

            addRecieptResponse.Message = "Reciept status not updated successfully.";

            if (String.IsNullOrEmpty(request.AuthToken))
            {
                addRecieptResponse.Message = "Please pass all mandatory fields.";
                return(addRecieptResponse);
            }

            AuthenticationToken authToken = new Helper().GetAuthenticationToken(request.AuthToken);

            if (authToken == null)
            {
                addRecieptResponse.Message = "Unauthorizes user.";
                return(addRecieptResponse);
            }

            RecieptEL recieptEL = new RecieptEL();

            recieptEL.Status = request.recieptDTO.Status;
            recieptEL.Price  = request.recieptDTO.Price;
            if (receiptHelper.UpdateOrderReceipt(recieptEL))
            {
                addRecieptResponse.Message   = "Reciept status updated successfully.";
                addRecieptResponse.IsSuccess = true;
                return(addRecieptResponse);
            }
            else
            {
                addRecieptResponse.Message = "Some error occured.";
                return(addRecieptResponse);
            }
        }