public virtual ActionResult UpsertCustomer(string CustomerPublicId) { UpserCustomerModel oModel = new UpserCustomerModel() { CustomerOptions = DocumentManagement.Customer.Controller.Customer.CatalogGetCustomerOptions(), RelatedCustomer = new CustomerModel() { CustomerPublicId = CustomerPublicId }, }; if (!string.IsNullOrEmpty(Request["UpsertAction"]) && Request["UpsertAction"].Trim() == "true") { oModel.RelatedCustomer = GetCustomerRequest(); oModel.RelatedCustomer.CustomerPublicId = DocumentManagement.Customer.Controller.Customer.CustomerUpsert(oModel.RelatedCustomer); return(RedirectToAction(MVC.Customer.ActionNames.UpsertCustomer, MVC.Customer.Name, new { CustomerPublicId = oModel.RelatedCustomer.CustomerPublicId })); } if (!string.IsNullOrEmpty(oModel.RelatedCustomer.CustomerPublicId)) { oModel.RelatedCustomer = DocumentManagement.Customer.Controller.Customer.CustomerGetById(oModel.RelatedCustomer.CustomerPublicId); } return(View(oModel)); }
public virtual ActionResult ListForm(string CustomerPublicId) { UpserCustomerModel oModel = new UpserCustomerModel() { RelatedCustomer = DocumentManagement.Customer.Controller.Customer.CustomerGetById(CustomerPublicId), }; return(View(oModel)); }
public virtual ActionResult UpsertForm(string CustomerPublicId, string FormPublicId) { UpserCustomerModel oModel = new UpserCustomerModel() { RelatedCustomer = DocumentManagement.Customer.Controller.Customer.CustomerGetById(CustomerPublicId), RelatedForm = new FormModel() { FormPublicId = FormPublicId }, }; if (!string.IsNullOrEmpty(Request["UpsertAction"]) && Request["UpsertAction"].Trim() == "true") { oModel.RelatedForm = GetFormRequest(); oModel.RelatedForm.FormPublicId = DocumentManagement.Customer.Controller.Customer.FormUpsert (oModel.RelatedCustomer.CustomerPublicId, oModel.RelatedForm); return(RedirectToAction(MVC.Customer.ActionNames.UpsertForm, MVC.Customer.Name, new { CustomerPublicId = oModel.RelatedCustomer.CustomerPublicId, FormPublicId = oModel.RelatedForm.FormPublicId, })); } if (!string.IsNullOrEmpty(oModel.RelatedForm.FormPublicId)) { oModel.RelatedForm = DocumentManagement.Customer.Controller.Customer. CustomerGetByFormId(oModel.RelatedForm.FormPublicId). RelatedForm. Where(x => x.FormPublicId == FormPublicId). FirstOrDefault(); } return(View(oModel)); }
public virtual ActionResult UploadProvider(string CustomerPublicId, HttpPostedFileBase ExcelFile) { //eval upsert action if (!string.IsNullOrEmpty(Request["UpsertAction"]) && Request["UpsertAction"].Trim() == "true") { try { string ProviderName = Request["ProviderName"].ToString(); string IdentificationNumber = Request["IdentificationNumber"].ToString(); string IdentificationType = Convert.ToInt32(Request["IdentificationType"]) == 0 ? string.Empty : Request["IdentificationType"]; string CheckDigit = string.IsNullOrEmpty(Request["CheckDigit"]) ? string.Empty : Request["CheckDigit"]; string Email = Request["Email"].ToString(); //string Salesforce = Request["Salesforce"].ToString(); #region Operation //Validate provider ProviderModel Provider = new ProviderModel(); ProviderModel oResultValidate = new ProviderModel(); ProviderModel oInfoValidate = new ProviderModel(); oResultValidate = DocumentManagement.Provider.Controller.Provider.ProviderGetByIdentification(IdentificationNumber, Convert.ToInt32(IdentificationType), CustomerPublicId); //Create ProviderCustomerInfo List <ProviderInfoModel> ListCustomerProviderInfo = new List <ProviderInfoModel>(); ProviderInfoModel CustomerProviderInfo = new ProviderInfoModel(); if (oResultValidate == null) { CustomerProviderInfo.ProviderInfoType = new CatalogModel() { ItemId = 401 }; CustomerProviderInfo.Value = "201"; ListCustomerProviderInfo.Add(CustomerProviderInfo); } CustomerProviderInfo = new ProviderInfoModel(); CustomerProviderInfo.ProviderInfoId = oResultValidate != null? oResultValidate.RelatedProviderCustomerInfo.Where(x => x.ProviderInfoType.ItemId == 378). Select(x => x.ProviderInfoId).FirstOrDefault() : 0; CustomerProviderInfo.ProviderInfoType = new CatalogModel() { ItemId = 378 }; CustomerProviderInfo.Value = CheckDigit; ListCustomerProviderInfo.Add(CustomerProviderInfo); //Create Provider ProviderModel ProviderToCreate = new ProviderModel() { CustomerPublicId = CustomerPublicId, Name = ProviderName, IdentificationType = new Provider.Models.Util.CatalogModel() { ItemId = Convert.ToInt32(IdentificationType) }, IdentificationNumber = IdentificationNumber, Email = Email, RelatedProviderCustomerInfo = ListCustomerProviderInfo }; if (oResultValidate == null) { DocumentManagement.Provider.Controller.Provider.ProviderUpsert(ProviderToCreate); ProviderToCreate.CustomerPublicId = DocumentManagement.Models.General.InternalSettings.Instance[DocumentManagement.Models.General.Constants.C_Settings_PublicId_Publicar].Value; ListCustomerProviderInfo.All(x => { x.ProviderInfoId = 0; return(true); }); DocumentManagement.Provider.Controller.Provider.ProviderCustomerInfoUpsert(ProviderToCreate); } else { ProviderToCreate.ProviderPublicId = oResultValidate.ProviderPublicId; DocumentManagement.Provider.Controller.Provider.ProviderCustomerInfoUpsert(ProviderToCreate); } #endregion } catch (Exception e) { } } if (ExcelFile != null) { string strFolder = Server.MapPath(DocumentManagement.Models.General.Constants.C_Settings_File_TempDirectory); if (!System.IO.Directory.Exists(strFolder)) { System.IO.Directory.CreateDirectory(strFolder); } //get File string strFile = strFolder.TrimEnd('\\') + "\\ProviderUploadFile_" + CustomerPublicId + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; string ErrorFilePath = strFile.Replace(".xls", "_log.csv"); ExcelFile.SaveAs(strFile); //load file to s3 string strRemoteFile = ProveedoresOnLine.FileManager.FileController.LoadFile (strFile, DocumentManagement.Models.General.InternalSettings.Instance[DocumentManagement.Models.General.Constants.C_Settings_File_ExcelDirectory].Value); //update file into db string logFile = this.ProccessProviderFile(strFile, ErrorFilePath, CustomerPublicId); //remove temporal file if (System.IO.File.Exists(strFile)) { System.IO.File.Delete(strFile); } //ViewData.Add(strRemoteFile); List <string> urlList = new List <string>(); urlList.Add(strRemoteFile); urlList.Add(logFile); ViewData["UrlReturn"] = urlList; UpserCustomerModel oModel = new UpserCustomerModel() { RelatedCustomer = DocumentManagement.Customer.Controller.Customer.CustomerGetById(CustomerPublicId), }; return(View(oModel)); } else { UpserCustomerModel oModel = new UpserCustomerModel() { RelatedCustomer = DocumentManagement.Customer.Controller.Customer.CustomerGetById(CustomerPublicId), }; return(View(oModel)); } }