コード例 #1
0
ファイル: QuotationController.cs プロジェクト: NLTDIndia/AMS
        public ActionResult Create(QuotationModel quotationModel, HttpPostedFileBase QuotationFile)
        {
            try
            {
                quotationModel.Vendorddl = _vendorService.GetDropdownVendors();
                if (ModelState.IsValid)
                {
                    string path = Server.MapPath("~/App_Data/Quotation/");
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    if (QuotationFile != null)
                    {
                        quotationModel.QuotationFilePath = string.Format("{0:yyyy-MM-dd_HH-mm-ss-fff}", quotationModel.QuotationReceivedDate) + ".pdf";
                        string fileName = Path.GetFileName(QuotationFile.FileName);
                        fileName = quotationModel.QuotationFilePath;
                        QuotationFile.SaveAs(path + fileName);
                    }
                    _quotationService.CreateQuotation(quotationModel);

                    TempData["Message"]     = "Quotation created successfully.";
                    TempData["MessageType"] = (int)AlertMessageTypes.Success;
                    return(RedirectToAction("ManageQuotation"));
                }
                else
                {
                    return(View(quotationModel));
                }
            }
            catch (Exception e)
            {
                _logger.Error(e);
                TempData["Message"]     = "Internal server error. Vendor not created. Please contact administrator.";
                TempData["MessageType"] = (int)AlertMessageTypes.Danger;
                return(View(quotationModel));
            }
        }