protected override void ValidateEntity(smART.ViewModel.Party entity) { if (string.IsNullOrEmpty(entity.Party_Name)) { ModelState.AddModelError("Name", "The Party Name field is required."); } if (string.IsNullOrEmpty(entity.Party_Short_Name)) { ModelState.AddModelError("ShortName", "The Short Name field is required."); } if (string.IsNullOrWhiteSpace(entity.Party_Type)) { ModelState.AddModelError("ShortName", "The Party Type Name field is required."); } if (entity.ID == 0) { IEnumerable <AddressBook> resultList = (IList <AddressBook>)Session["AddressBook"]; if (resultList == null || resultList.Count() <= 0) { ModelState.AddModelError("Address", "The Party address is required."); } } if (entity.Party_Type == "Individual" && string.IsNullOrEmpty(entity.License_No)) { ModelState.AddModelError("License", "License# is required."); } }
public JsonResult _SaveCustomerImages(string scaleId, string partyId) { try { if (!string.IsNullOrEmpty(partyId)) { // Get party PartyLibrary partyLib = new PartyLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); smART.ViewModel.Party party = partyLib.GetByID(partyId); if (party != null) { FilelHelper fileHelper = new FilelHelper(); string filePath; // Save Customer Image if (!string.IsNullOrEmpty(party.PhotoRefId)) { filePath = fileHelper.GetFilePathByFileRefId(party.PhotoRefId); if (System.IO.File.Exists(filePath)) { Byte[] photoBytes = fileHelper.GetBytesFromFile(filePath); SaveAttachment(Convert.ToInt32(scaleId), photoBytes, CommonHelper.GetFileNameByDocType((int)EnumAttachmentRefType.Customer), EnumAttachmentRefType.Customer, FileFormat.jpeg); } } // Signature Image if (!string.IsNullOrEmpty(party.SignatureImageRefId)) { filePath = fileHelper.GetFilePathByFileRefId(party.SignatureImageRefId); if (System.IO.File.Exists(filePath)) { Byte[] photoBytes = fileHelper.GetBytesFromFile(filePath); SaveAttachment(Convert.ToInt32(scaleId), photoBytes, CommonHelper.GetFileNameByDocType((int)EnumAttachmentRefType.Signature), EnumAttachmentRefType.Signature, FileFormat.bmp); } } // Thumb Image if (!string.IsNullOrEmpty(party.ThumbImage1RefId)) { filePath = fileHelper.GetFilePathByFileRefId(party.ThumbImage1RefId); if (System.IO.File.Exists(filePath)) { Byte[] photoBytes = fileHelper.GetBytesFromFile(filePath); SaveAttachment(Convert.ToInt32(scaleId), photoBytes, CommonHelper.GetFileNameByDocType((int)EnumAttachmentRefType.Thumbprint1), EnumAttachmentRefType.Thumbprint1, FileFormat.jpg); } } // License Image if (!string.IsNullOrEmpty(party.LicenseImageRefId)) { filePath = fileHelper.GetFilePathByFileRefId(party.LicenseImageRefId); if (System.IO.File.Exists(filePath)) { Byte[] photoBytes = fileHelper.GetBytesFromFile(filePath); SaveAttachment(Convert.ToInt32(scaleId), photoBytes, CommonHelper.GetFileNameByDocType((int)EnumAttachmentRefType.DriverLicense), EnumAttachmentRefType.DriverLicense, FileFormat.jpg); } } // Vehicle Image if (!string.IsNullOrEmpty(party.VehicleImageRegId)) { filePath = fileHelper.GetFilePathByFileRefId(party.VehicleImageRegId); if (System.IO.File.Exists(filePath)) { Byte[] photoBytes = fileHelper.GetBytesFromFile(filePath); SaveAttachment(Convert.ToInt32(scaleId), photoBytes, CommonHelper.GetFileNameByDocType((int)EnumAttachmentRefType.Vehicle), EnumAttachmentRefType.Vehicle, FileFormat.jpg); } } // Cash Card Image if (!string.IsNullOrEmpty(party.CashCardImageRefId)) { filePath = fileHelper.GetFilePathByFileRefId(party.CashCardImageRefId); if (System.IO.File.Exists(filePath)) { Byte[] photoBytes = fileHelper.GetBytesFromFile(filePath); SaveAttachment(Convert.ToInt32(scaleId), photoBytes, CommonHelper.GetFileNameByDocType((int)EnumAttachmentRefType.CashCard), EnumAttachmentRefType.CashCard, FileFormat.jpg); } } } } return(Json(new { Sucess = "True" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Sucess = ex.Message }, JsonRequestBehavior.AllowGet)); } }