Ejemplo n.º 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);
        }
        public static NegotiationViewModel ConvertToVm(TblNegotiation model)
        {
            NegotiationViewModel vm = new NegotiationViewModel()
            {
                id        = model.id,
                productId = model.productId,
                quantity  = model.quantity,
                negotiatedPricePerItem = model.negotiatedPricePerItem,
                date                = model.negotiationDateTime.Date.ToShortDateString(),
                time                = model.negotiationDateTime.ToString("hh:mm tt"),
                totalAmount         = model.totalAmount,
                status              = model.status,
                negotiationDateTime = model.negotiationDateTime,
                orderId             = model.orderId
            };

            return(vm);
        }
        /// <summary>
        /// Negotiation validation
        /// </summary>
        public static bool ValidateOrderLineOrNegotiation(TblNegotiation negotiation)
        {
            bool isValid = false;

            try
            {
                isValid = GeneralValidator.IsNumeric(negotiation.productId) &&
                          GeneralValidator.IsDecimalNumber(negotiation.quantity) &&
                          GeneralValidator.IsDecimalNumber(negotiation.negotiatedPricePerItem) &&
                          GeneralValidator.IsDecimalNumber(negotiation.totalAmount) &&
                          GeneralValidator.IsStringNotEmpty(negotiation.status) &&
                          GeneralValidator.IsNumeric(negotiation.orderId);
            }
            catch (Exception)
            {
                return(isValid);
            }
            return(isValid);
        }