public async Task <ActionResult> Edit(ManageCourierModel model) { try { if (ModelState.IsValid) { using (var con = new SqlConnection(_connectionString)) { var path = Server.MapPath("/UploadedImages/Courier/"); if (model.UploadedCourierFilePath != null && model.UploadedCourierFile != null) { if (System.IO.File.Exists(path + "Logo/ " + model.UploadedCourierFile)) { System.IO.File.Delete(path + "Logo/" + model.UploadedCourierFile); } } if (model.UploadedCourierFilePath != null) { model.UploadedCourierFile = SaveImageFile(model.UploadedCourierFilePath, "Courier/Logo"); } if (model.UploadedGSTFilePath != null && model.UploadedGSTFile != null) { if (System.IO.File.Exists(path + "Gst/ " + model.UploadedGSTFile)) { System.IO.File.Delete(path + "Gst/" + model.UploadedGSTFile); } } if (model.UploadedGSTFilePath != null) { model.UploadedGSTFile = SaveImageFile(model.UploadedGSTFilePath, "Courier/Logo"); } if (model.PANCardFilePath != null && model.PANCardFile != null) { if (System.IO.File.Exists(path + "PanCards/ " + model.PANCardFile)) { System.IO.File.Delete(path + "PanCards/" + model.PANCardFile); } } if (model.PANCardFilePath != null) { model.PANCardFile = SaveImageFile(model.PANCardFilePath, "Courier/Logo"); } if (model.UserPANCardFilePath != null && model.UserPANCardFile != null) { if (System.IO.File.Exists(path + "PanCards/ " + model.UserPANCardFile)) { System.IO.File.Delete(path + "PanCards/" + model.UserPANCardFile); } } if (model.UserPANCardFilePath != null) { model.UserPANCardFile = SaveImageFile(model.UserPANCardFilePath, "Courier/Logo"); } if (model.VoterIDFilePath != null && model.VoterIDFile != null) { if (System.IO.File.Exists(path + "VoterCards/ " + model.VoterIDFile)) { System.IO.File.Delete(path + "VoterCards/" + model.VoterIDFile); } } if (model.VoterIDFilePath != null) { model.VoterIDFile = SaveImageFile(model.VoterIDFilePath, "Courier/Logo"); } if (model.AadhaarCardFilePath != null && model.AadhaarCardFile != null) { if (System.IO.File.Exists(path + "AdharCards/ " + model.AadhaarCardFile)) { System.IO.File.Delete(path + "AdharCards/" + model.AadhaarCardFile); } } if (model.AadhaarCardFilePath != null) { model.AadhaarCardFile = SaveImageFile(model.AadhaarCardFilePath, "Courier/Logo"); } if (model.AgreementScanFilePath != null && model.AgreementScanFile != null) { if (System.IO.File.Exists(path + "ScanAgreement/ " + model.AgreementScanFile)) { System.IO.File.Delete(path + "ScanAgreement/" + model.AgreementScanFile); } } if (model.AgreementScanFilePath != null) { model.AgreementScanFile = SaveImageFile(model.AgreementScanFilePath, "Courier/Logo"); } if (model.CancelledChequeFilePath != null && model.CancelledChequeFile != null) { if (System.IO.File.Exists(path + "CancelledCheques/ " + model.CancelledChequeFile)) { System.IO.File.Delete(path + "CancelledCheques/" + model.CancelledChequeFile); } } if (model.CancelledChequeFilePath != null) { model.CancelledChequeFile = SaveImageFile(model.CancelledChequeFilePath, "Courier/Logo"); } var result = con.Query <int>("Add_Modify_Delete_Courier", new { //Settings model.CourierId, model.CourierName, model.CourierCode, model.CourierBrandName, model.Priority, model.CourierTAT, model.AWBNumber, //CountryId = model.Country, //StateId = model.StateDropdown, // CityId = model.CityDropdown, model.CountryId, model.StateId, model.CityId, model.UploadedCourierFile, model.IsReverse, model.IsAllowPreference, //Organisation model.CourierCompanyName, model.OrganizationCode, model.StatutoryType, model.ApplicableTaxType, model.GSTNumber, model.UploadedGSTFile, model.PANCardNumber, model.PANCardFile, model.BikeMakeandModel, model.BikeNumber, //Address and Contact Person model.PersonAddresstype, PersonCountry = model.PersonCountryDropdown, PersonState = model.PersonStateDropdown, PersonCity = model.PersonCityDropdown, model.FullAddress, model.Locality, model.NearByLocation, model.Pincode, model.FirstName, model.LastName, model.MobileNumber, model.EmailAddress, model.UserPANCard, model.UserPANCardFile, model.VoterIDCardNo, model.VoterIDFile, model.AadhaarCardNo, model.AadhaarCardFile, model.IsUser, //Service Charge SC_Country = model.SC_CountryDropdown, SC_Pincode = model.SC_PincodeDropdown, model.Currency, model.ServiceChargeType, model.ValueRange, WeightRange = model.WeightRange1 + "-" + model.WeightRange2, Volume = model.Volumn1 + "-" + model.Volumn2, model.ServiceCharge, model.ApplicableFromDate, model.ItemType, //Agreement model.LegalDocumentVerificationStatus, model.AgreementSignupStatus, model.AgreementStartDate, model.AgreementEndDate, model.AgreementNumber, model.AgreementScanFile, //Bank Details model.BankName, model.BankAccountNumber, model.CompanyNameatBank, model.IFSCCode, model.BankBranch, model.CancelledChequeFile, model.PaymentCycle, //Registration model.LuluandSky_Status, model.Comments, model.IsActive, User = CurrentUser.UserId, CurrentUser.CompanyId, Action = "U", }, commandType: CommandType.StoredProcedure).FirstOrDefault(); var response = new ResponseModel(); if (result == 2) { response.IsSuccess = true; response.Response = "Courier Name Updated Successfully"; TempData["response"] = response; TempData.Keep("response"); } else { response.IsSuccess = true; response.Response = "Courier Name Not Updated Successfully"; TempData["response"] = response; TempData.Keep("response"); } return(RedirectToAction("ManageCourier")); } } else { model.CountryList = new SelectList(dropdown.BindCountry(), "Value", "Text"); model.StateList = new SelectList(Enumerable.Empty <SelectListItem>()); model.CityList = new SelectList(Enumerable.Empty <SelectListItem>()); model.PincodeList = new SelectList(Enumerable.Empty <SelectListItem>()); model.ApplicableTaxTypeList = new SelectList(await CommonModel.GetApplicationTaxType(), "Value", "Text"); model.PersonAddressTypeList = new SelectList(CommonModel.GetAddressTypes(), "Value", "Text"); model.AWBNumberUsedList = new SelectList(await CommonModel.GetAWBNumberUsedTypes(), "Value", "Text"); model.AgreementSignupList = new SelectList(await CommonModel.GetAgreementSignup(), "Value", "Text"); model.LegalDocumentVerificationList = new SelectList(await CommonModel.GetLegalDocumentVerification(), "Value", "Text"); return(View(model)); } } catch (Exception e) { model.CountryList = new SelectList(dropdown.BindCountry(), "Value", "Text"); model.StateList = new SelectList(Enumerable.Empty <SelectListItem>()); model.CityList = new SelectList(Enumerable.Empty <SelectListItem>()); model.PincodeList = new SelectList(Enumerable.Empty <SelectListItem>()); model.ApplicableTaxTypeList = new SelectList(await CommonModel.GetApplicationTaxType(), "Value", "Text"); model.PersonAddressTypeList = new SelectList(CommonModel.GetAddressTypes(), "Value", "Text"); model.AWBNumberUsedList = new SelectList(await CommonModel.GetAWBNumberUsedTypes(), "Value", "Text"); model.AgreementSignupList = new SelectList(await CommonModel.GetAgreementSignup(), "Value", "Text"); model.LegalDocumentVerificationList = new SelectList(await CommonModel.GetLegalDocumentVerification(), "Value", "Text"); return(View(model)); } }