public void createfolder(string subFolderName, string officeCode, string DestinationPath)
{
if (!Directory.Exists(DestinationPath.Trim()))
{
DirectoryInfo di = Directory.CreateDirectory(DestinationPath.Trim());
}
if (!Directory.Exists(Path.Combine(DestinationPath.Trim(), officeCode)))
{
DirectoryInfo di = Directory.CreateDirectory(Path.Combine(DestinationPath.Trim(), officeCode));
}
if (!Directory.Exists(Path.Combine(DestinationPath.Trim(), officeCode, subFolderName)))
{
DirectoryInfo di = Directory.CreateDirectory(Path.Combine(DestinationPath.Trim(), officeCode, subFolderName));
}
}
[HttpPost]
public ActionResult Save(BOOfficeMaster bOOfficeMaster)
{
if (ModelState.IsValid)
{
bLOfficeMaster.Save(bOOfficeMaster);
var m = bLOfficeMaster.GetOfficeMaster().OrderByDescending(n => n.PSASOfficeCode).First();
PSAS.Models.CustomerMaster.BusinessLayer.BLCustomerMaster oBLCustomerMaster = new Models.CustomerMaster.BusinessLayer.BLCustomerMaster();
string officeCode = m.PSASOfficeCode.ToString();
PSAS.Models.CustomerMaster.BusinessObject.BODocumentPathConfig oBODocumentPathConfig = null;
oBODocumentPathConfig = oBLCustomerMaster.getDocumentPathConfig(91);
createfolder("PASARALICENCE", officeCode, oBODocumentPathConfig.DestinationPath);
DestinationPath="C:\PSASMVC\AppDocument\PSASOFFICEDOCUMENT\";
createfolder("SHOPANDESTABLISHMENTLICENCE", officeCode, oBODocumentPathConfig.DestinationPath);
createfolder("RENTAGREEMENT", officeCode, oBODocumentPathConfig.DestinationPath);
createfolder("TRAININGCERTIFICATE", officeCode, oBODocumentPathConfig.DestinationPath);
if (bOOfficeMaster.PasaraLicencefu.ContentLength > 0)
bOOfficeMaster.PasaraLicencefu.SaveAs(Path.Combine(oBODocumentPathConfig.DestinationPath.Trim(), officeCode, "PASARALICENCE", bOOfficeMaster.PasaraLicencefu.FileName));
if (bOOfficeMaster.ShopEstablishmentLicencefu.ContentLength > 0)
bOOfficeMaster.ShopEstablishmentLicencefu.SaveAs(Path.Combine(oBODocumentPathConfig.DestinationPath.Trim(), officeCode, "SHOPANDESTABLISHMENTLICENCE", bOOfficeMaster.ShopEstablishmentLicencefu.FileName));
if (bOOfficeMaster.RentAgreementfu.ContentLength > 0)
bOOfficeMaster.RentAgreementfu.SaveAs(Path.Combine(oBODocumentPathConfig.DestinationPath.Trim(), officeCode, "RENTAGREEMENT", bOOfficeMaster.RentAgreementfu.FileName));
if (bOOfficeMaster.TrainingCertificatefu.ContentLength > 0)
bOOfficeMaster.TrainingCertificatefu.SaveAs(Path.Combine(oBODocumentPathConfig.DestinationPath.Trim(), officeCode, "TRAININGCERTIFICATE", bOOfficeMaster.TrainingCertificatefu.FileName));
TempData["success"] = "Data Saved Successfully.";
}
return RedirectToAction("Index");
}
{
if (!Directory.Exists(DestinationPath.Trim()))
{
DirectoryInfo di = Directory.CreateDirectory(DestinationPath.Trim());
}
if (!Directory.Exists(Path.Combine(DestinationPath.Trim(), officeCode)))
{
DirectoryInfo di = Directory.CreateDirectory(Path.Combine(DestinationPath.Trim(), officeCode));
}
if (!Directory.Exists(Path.Combine(DestinationPath.Trim(), officeCode, subFolderName)))
{
DirectoryInfo di = Directory.CreateDirectory(Path.Combine(DestinationPath.Trim(), officeCode, subFolderName));
}
}
[HttpPost]
public ActionResult Save(BOOfficeMaster bOOfficeMaster)
{
if (ModelState.IsValid)
{
bLOfficeMaster.Save(bOOfficeMaster);
var m = bLOfficeMaster.GetOfficeMaster().OrderByDescending(n => n.PSASOfficeCode).First();
PSAS.Models.CustomerMaster.BusinessLayer.BLCustomerMaster oBLCustomerMaster = new Models.CustomerMaster.BusinessLayer.BLCustomerMaster();
string officeCode = m.PSASOfficeCode.ToString();
PSAS.Models.CustomerMaster.BusinessObject.BODocumentPathConfig oBODocumentPathConfig = null;
oBODocumentPathConfig = oBLCustomerMaster.getDocumentPathConfig(91);
createfolder("PASARALICENCE", officeCode, oBODocumentPathConfig.DestinationPath);
DestinationPath="C:\PSASMVC\AppDocument\PSASOFFICEDOCUMENT\";
createfolder("SHOPANDESTABLISHMENTLICENCE", officeCode, oBODocumentPathConfig.DestinationPath);
createfolder("RENTAGREEMENT", officeCode, oBODocumentPathConfig.DestinationPath);
createfolder("TRAININGCERTIFICATE", officeCode, oBODocumentPathConfig.DestinationPath);
if (bOOfficeMaster.PasaraLicencefu.ContentLength > 0)
bOOfficeMaster.PasaraLicencefu.SaveAs(Path.Combine(oBODocumentPathConfig.DestinationPath.Trim(), officeCode, "PASARALICENCE", bOOfficeMaster.PasaraLicencefu.FileName));
if (bOOfficeMaster.ShopEstablishmentLicencefu.ContentLength > 0)
bOOfficeMaster.ShopEstablishmentLicencefu.SaveAs(Path.Combine(oBODocumentPathConfig.DestinationPath.Trim(), officeCode, "SHOPANDESTABLISHMENTLICENCE", bOOfficeMaster.ShopEstablishmentLicencefu.FileName));
if (bOOfficeMaster.RentAgreementfu.ContentLength > 0)
bOOfficeMaster.RentAgreementfu.SaveAs(Path.Combine(oBODocumentPathConfig.DestinationPath.Trim(), officeCode, "RENTAGREEMENT", bOOfficeMaster.RentAgreementfu.FileName));
if (bOOfficeMaster.TrainingCertificatefu.ContentLength > 0)
bOOfficeMaster.TrainingCertificatefu.SaveAs(Path.Combine(oBODocumentPathConfig.DestinationPath.Trim(), officeCode, "TRAININGCERTIFICATE", bOOfficeMaster.TrainingCertificatefu.FileName));
TempData["success"] = "Data Saved Successfully.";
}
return RedirectToAction("Index");
}
No comments:
Post a Comment