public ActionResult Index(string submitButton, SalesQuotationViewModels model, HttpPostedFileBase file) { try { //ApplicationUser currentUser = ApplicationUserManager.GetApplicationUser(User.Identity.Name, HttpContext.GetOwinContext()); if (submitButton == "Save") { model.SalesQuotation.Document_Date = DateTime.Now; model.SalesQuotation.Doc_Status = "Open"; model.SalesQuotation.Created_Branc_Id = CurrentBranchId; model.SalesQuotation.Created_Date = DateTime.Now; model.SalesQuotation.Created_User_Id = CurrentUser.Id; //GetUserId() //model.SalesQuotation.Modified_User_Id = CurrentUser.Id; //model.SalesQuotation.Modified_Date = DateTime.Now; //model.SalesQuotation.Modified_Branch_Id = CurrentBranchId; var QuotationList = model.SalesQuotationItemList.Where(x => x.IsDummy == 0); model.SalesQuotationItemList = QuotationList.ToList(); if (salesquotationRepository.AddNewQuotation(model.SalesQuotation, model.SalesQuotationItemList, ref ErrorMessage)) { //XMLGenerate_SAPInsert(model); //for (int i = 0; i < model.PurchaseQuotationItemList.Count; i++) //{ // XMLGenerate_Quotation_SAPInsert(model.PurchaseQuotationItemList[i]); //} return(RedirectToAction("Index", "SalesQuotations")); } else { ViewBag.AppErrorMessage = ErrorMessage; return(View("Error")); } } else if (submitButton == "Update") { model.SalesQuotation.Document_Date = DateTime.Now; model.SalesQuotation.Doc_Status = "Open"; //model.SalesQuotation.Created_Branc_Id = CurrentBranchId; //model.SalesQuotation.Created_Date = DateTime.Now; //model.SalesQuotation.Created_User_Id = CurrentUser.Id; //GetUserId() model.SalesQuotation.Modified_User_Id = CurrentUser.Id; model.SalesQuotation.Modified_Date = DateTime.Now; model.SalesQuotation.Modified_Branch_Id = CurrentBranchId; //var QuotationList = model.PurchaseQuotationItemList.Where(x => x.IsDummy == 0); //model.PurchaseQuotationItemList = QuotationList.ToList(); //for (int i = 0; i < model.PurchaseQuotationItemList.Count; i++) //{ // model.PurchaseQuotationItemList[i].Quoted_qty = 10; //GetQuantity() // model.PurchaseQuotationItemList[i].Quoted_date = DateTime.Now; //} if (salesquotationRepository.UpdateQuotation(model.SalesQuotation, model.SalesQuotationItemList, ref ErrorMessage)) { //XMLGenerate_SAPUpdate(model); return(RedirectToAction("Index", "SalesQuotations")); } else { ViewBag.AppErrorMessage = ErrorMessage; return(View("Error")); } } return(RedirectToAction("Index", "SalesQuotations")); } catch (Exception ex) { ExceptionHandler.LogException(ex); ViewBag.AppErrorMessage = ex.Message; return(View("Error")); } }