Example #1
0
        /// <summary>
        /// convert price sheet to list model
        /// </summary>
        /// <param name="priceSheet"></param>
        /// <returns></returns>
        public PriceSheetListModel ConvertToListView(PriceSheet priceSheet)
        {
            PriceSheetListModel model = new PriceSheetListModel();

            var _rfqRepository = new RfqRepository();
            var _customerDynamicsRepository = new CustomerDynamicsRepository();

            var rfq = _rfqRepository.GetRfq(priceSheet.RfqId);
            var dynamicsCustomer = _customerDynamicsRepository.GetCustomer((rfq != null) ? rfq.CustomerId : string.Empty);

            model.PriceSheetId  = priceSheet.PriceSheetId;
            model.Number        = (!string.IsNullOrEmpty(priceSheet.Number)) ? priceSheet.Number : "N/A";
            model.Date          = (priceSheet.CreatedDate != null) ? priceSheet.CreatedDate : DateTime.MinValue;
            model.DateStr       = (priceSheet.CreatedDate != null) ? priceSheet.CreatedDate.Value.ToShortDateString() : "N/A";
            model.CustomerName  = (dynamicsCustomer != null && !string.IsNullOrEmpty(dynamicsCustomer.SHRTNAME)) ? dynamicsCustomer.SHRTNAME : "N/A";
            model.RfqNumber     = (rfq != null && !string.IsNullOrEmpty(rfq.Number)) ? rfq.Number : "N/A";
            model.ProjectMargin = priceSheet.ProjectMargin;
            model.WAF           = priceSheet.WAF;
            model.Status        = priceSheet.IsQuote ? "Quote" : priceSheet.IsProduction ? "Production" : "N/A";
            model.CreatedDate   = (priceSheet.CreatedDate != null) ? priceSheet.CreatedDate : DateTime.MinValue;

            if (_rfqRepository != null)
            {
                _rfqRepository.Dispose();
                _rfqRepository = null;
            }

            if (_customerDynamicsRepository != null)
            {
                _customerDynamicsRepository.Dispose();
                _customerDynamicsRepository = null;
            }

            return(model);
        }
Example #2
0
        public ActionResult Index()
        {
            PriceSheetListModel model = new PriceSheetListModel();

            model.PriceSheets = new List <PriceSheetListModel>();

            var priceSheets = _priceSheetRepository.GetPriceSheets().Where(x => x.IsProduction).ToList();

            if (priceSheets != null && priceSheets.Count > 0)
            {
                foreach (var priceSheet in priceSheets)
                {
                    PriceSheetListModel sheetModel = new PriceSheetConverter().ConvertToListView(priceSheet);

                    model.PriceSheets.Add(sheetModel);
                }
            }

            return(View(model));
        }
Example #3
0
        public JsonResult GetQuotePriceSheets()
        {
            var model = new PriceSheetListModel();

            var priceSheets = new List <PriceSheetListModel>();

            var tempPriceSheets = _priceSheetRepository.GetPriceSheets().Where(x => x.IsQuote).ToList();

            if (tempPriceSheets != null && tempPriceSheets.Count > 0)
            {
                foreach (var tempPriceSheet in tempPriceSheets)
                {
                    var priceSheetModel = new PriceSheetConverter().ConvertToListView(tempPriceSheet);

                    priceSheets.Add(priceSheetModel);
                }
            }

            model.PriceSheets = priceSheets.OrderBy(x => x.Number).ToList();

            return(Json(model, JsonRequestBehavior.AllowGet));
        }