Beispiel #1
0
        public string SaveNegotiation(int productListId, decimal quantityVal, decimal pricePerItem, decimal totalAmountVal, int status, int orderIdVal)
        {
            string message = string.Empty;

            try
            {
                // validation
                if (OrderLineNegotiationValidator.ValidateOrderLineOrNegotiation(productListId, quantityVal, pricePerItem, totalAmountVal, status, orderIdVal))
                {
                    TblNegotiation negotiation = new TblNegotiation()
                    {
                        productId = productListId,
                        quantity  = quantityVal,
                        negotiatedPricePerItem = pricePerItem,
                        totalAmount            = totalAmountVal,
                        status = CommonBehaviour.GetCommonStatusString(status),
                        negotiationDateTime = DateTime.Now,
                        orderId             = orderIdVal
                    };
                    negotiationRepository.Insert(negotiation);
                    unitOfWork.Save();
                    message = "success";
                }
                else
                {
                    message = "Error - Please fill all the mandatory fields";
                }
            }
            catch (Exception ex)
            {
                message = "Error - Server side - Saving negotiation. Please contact IT Support";
            }
            return(message);
        }
Beispiel #2
0
        public IList <OrderLineViewModel> SavePastOrderlineWithNegotiation(int productListId, decimal quantityVal, decimal pricePerItem, decimal totalAmountVal, int statusVal, int orderIdVal, DateTime orderDate)
        {
            try
            {
                // validation
                if (OrderLineNegotiationValidator.ValidateOrderLineOrNegotiation(productListId, quantityVal, pricePerItem, totalAmountVal, statusVal, orderIdVal))
                {
                    string status = CommonBehaviour.GetCommonStatusString(statusVal);
                    // call stored procedure via repository
                    var result = orderLineRepository.SQLQuery <OrderLineViewModel>("SP_SavePastOrderLineWithNegotiation @productListId, @quantityVal, @pricePerItem, @totalAmountVal, @status, @orderIdVal, @orderDate",
                                                                                   new SqlParameter("productListId", SqlDbType.Int)
                    {
                        Value = productListId
                    },
                                                                                   new SqlParameter("quantityVal", SqlDbType.Int)
                    {
                        Value = quantityVal
                    },
                                                                                   new SqlParameter("pricePerItem", SqlDbType.Decimal)
                    {
                        Value = pricePerItem
                    },
                                                                                   new SqlParameter("totalAmountVal", SqlDbType.Decimal)
                    {
                        Value = totalAmountVal
                    },
                                                                                   new SqlParameter("status", SqlDbType.Text)
                    {
                        Value = status
                    },
                                                                                   new SqlParameter("orderIdVal", SqlDbType.Int)
                    {
                        Value = orderIdVal
                    },
                                                                                   new SqlParameter("orderDate", SqlDbType.DateTime)
                    {
                        Value = orderDate
                    });

                    // convert the result orderlines (by order ID)
                    IList <OrderLineViewModel> orderLinesOfOrder = result.ToList <OrderLineViewModel>();
                    orderLinesOfOrder = CommonBehaviour.FixDateTime(orderLinesOfOrder);
                    return(orderLinesOfOrder);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }