public UserPersonalDetail Update(UserPersonalDetail userPersonalDetail, UserPersonalDetailUpsert obj) { string[] permittedExtensions = { ".jpg", ".jpeg", ".png", ".pdf" }; userPersonalDetail.MaritalStatus = obj.MaritalStatus; userPersonalDetail.Address = obj.Address; userPersonalDetail.MobileNumber = obj.MobileNumber; userPersonalDetail.Instagram = obj.Instagram; userPersonalDetail.Twitter = obj.Twitter; userPersonalDetail.Facebook = obj.Facebook; userPersonalDetail.USAddress = obj.USAddress; userPersonalDetail.Title = obj.Title; userPersonalDetail.Gender = obj.Gender; userPersonalDetail.FirstLanguage = obj.FirstLanguage; userPersonalDetail.Nationality = obj.Nationality; userPersonalDetail.DOB = obj.DOB; userPersonalDetail.IdentificationDocNo = obj.IdentificationDocNo; userPersonalDetail.TownCity = obj.TownCity; userPersonalDetail.StateCountry = obj.StateCountry; userPersonalDetail.ZipPostalCode = obj.ZipPostalCode; userPersonalDetail.TelephoneNumber = obj.TelephoneNumber; userPersonalDetail.OccupationSector = obj.OccupationSector; userPersonalDetail.OccupationLevel = obj.OccupationLevel; if (obj.IdentificationDoc != null) { var ext = Path.GetExtension(obj.IdentificationDoc.FileName); if (permittedExtensions.Contains(ext)) { ImageHelper.DeleteImage(_hostEnvironment, @"Uploads\UserPersonalDetail\IdentificationDoc", userPersonalDetail.IdentificationDoc.Replace("/Uploads/UserPersonalDetail/IdentificationDoc/", "")); userPersonalDetail.IdentificationDoc = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserPersonalDetail/IdentificationDoc", obj.IdentificationDoc); } } if (obj.CivilIDFront != null) { var ext = Path.GetExtension(obj.CivilIDFront.FileName); if (permittedExtensions.Contains(ext)) { ImageHelper.DeleteImage(_hostEnvironment, @"Uploads\UserPersonalDetail\CivilIDFront", userPersonalDetail.CivilIDFront.Replace("/Uploads/UserPersonalDetail/CivilIDFront/", "")); userPersonalDetail.CivilIDFront = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserPersonalDetail/CivilIDFront", obj.CivilIDFront); } } if (obj.CivilIDBack != null) { var ext = Path.GetExtension(obj.CivilIDBack.FileName); if (permittedExtensions.Contains(ext)) { ImageHelper.DeleteImage(_hostEnvironment, @"Uploads\UserPersonalDetail\CivilIDBack", userPersonalDetail.CivilIDBack.Replace("/Uploads/UserPersonalDetail/CivilIDBack/", "")); userPersonalDetail.CivilIDBack = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserPersonalDetail/CivilIDBack", obj.CivilIDBack); } } return(userPersonalDetail); }
public UserPersonalDetail Add(UserPersonalDetailUpsert obj) { string[] permittedExtensions = { ".jpg", ".jpeg", ".png", ".pdf" }; UserPersonalDetail userPersonalDetail = new UserPersonalDetail(); var ext1 = Path.GetExtension(obj.IdentificationDoc.FileName); var ext2 = Path.GetExtension(obj.CivilIDFront.FileName); var ext3 = Path.GetExtension(obj.CivilIDBack.FileName); if ((obj.IdentificationDoc != null && permittedExtensions.Contains(ext1))) { userPersonalDetail.IdentificationDoc = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserPersonalDetail/IdentificationDoc", obj.IdentificationDoc); } if ((obj.CivilIDFront != null && permittedExtensions.Contains(ext2))) { userPersonalDetail.CivilIDFront = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserPersonalDetail/CivilIDFront", obj.CivilIDFront); } if ((obj.CivilIDBack != null && permittedExtensions.Contains(ext3))) { userPersonalDetail.CivilIDBack = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserPersonalDetail/CivilIDBack", obj.CivilIDBack); } userPersonalDetail.UserID = obj.UserID; userPersonalDetail.MaritalStatus = obj.MaritalStatus; userPersonalDetail.Address = obj.Address; userPersonalDetail.MobileNumber = obj.MobileNumber; userPersonalDetail.Instagram = obj.Instagram; userPersonalDetail.Twitter = obj.Twitter; userPersonalDetail.Facebook = obj.Facebook; userPersonalDetail.USAddress = obj.USAddress; userPersonalDetail.Title = obj.Title; userPersonalDetail.Gender = obj.Gender; userPersonalDetail.FirstLanguage = obj.FirstLanguage; userPersonalDetail.Nationality = obj.Nationality; userPersonalDetail.DOB = obj.DOB; userPersonalDetail.IdentificationDocNo = obj.IdentificationDocNo; userPersonalDetail.TownCity = obj.TownCity; userPersonalDetail.StateCountry = obj.StateCountry; userPersonalDetail.ZipPostalCode = obj.ZipPostalCode; userPersonalDetail.TelephoneNumber = obj.TelephoneNumber; userPersonalDetail.OccupationSector = obj.OccupationSector; userPersonalDetail.OccupationLevel = obj.OccupationLevel; return(userPersonalDetail); }