Example #1
0
        public UserFamilyDetail Update(UserFamilyDetail userFamilyDetail, UserFamilyDetailUpsert obj)
        {
            string[] permittedExtensions = { ".jpg", ".jpeg", ".png", ".pdf" };
            userFamilyDetail.UserID                = obj.UserID;
            userFamilyDetail.ParentMobileNo        = obj.ParentMobileNo;
            userFamilyDetail.FriendInUS            = obj.FriendInUS;
            userFamilyDetail.FriendAddress         = obj.FriendAddress;
            userFamilyDetail.FriendMobileNo        = obj.FriendMobileNo;
            userFamilyDetail.FamilyMemberInUS      = obj.FamilyMemberInUS;
            userFamilyDetail.FamilyMemberFirstName = obj.FamilyMemberFirstName;
            userFamilyDetail.FamilyMemberLastName  = obj.FamilyMemberLastName;
            userFamilyDetail.FamilyMemberRelation  = obj.FamilyMemberRelation;
            userFamilyDetail.FamilyMemberUSCitizen = obj.FamilyMemberUSCitizen;
            userFamilyDetail.FamilyMemberImmigrant = obj.FamilyMemberImmigrant;
            userFamilyDetail.FamilyMemberRole      = obj.FamilyMemberRole;
            userFamilyDetail.CollegeUniversity     = obj.CollegeUniversity;
            userFamilyDetail.Major            = obj.Major;
            userFamilyDetail.OrganizationName = obj.OrganizationName;
            userFamilyDetail.MonthlySalary    = obj.MonthlySalary;
            userFamilyDetail.Currency         = obj.Currency;
            userFamilyDetail.Position         = obj.Position;
            if (obj.ParentPassport != null)
            {
                var ext = Path.GetExtension(obj.ParentPassport.FileName);
                if (permittedExtensions.Contains(ext))
                {
                    ImageHelper.DeleteImage(_hostEnvironment, @"Uploads\UserFamilyDetail\ParentPassport", userFamilyDetail.ParentPassport.Replace("/Uploads/UserFamilyDetail/ParentPassport/", ""));
                    userFamilyDetail.ParentPassport = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/ParentPassport", obj.ParentPassport);
                }
            }
            if (obj.FatherCivilIDBack != null)
            {
                var ext = Path.GetExtension(obj.FatherCivilIDBack.FileName);
                if (permittedExtensions.Contains(ext))
                {
                    ImageHelper.DeleteImage(_hostEnvironment, @"Uploads\UserFamilyDetail\FatherCivilIDBack", userFamilyDetail.FatherCivilIDBack.Replace("/Uploads/UserFamilyDetail/FatherCivilIDBack/", ""));
                    userFamilyDetail.FatherCivilIDBack = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/FatherCivilIDBack", obj.FatherCivilIDBack);
                }
            }
            if (obj.FatherCivilIDFront != null)
            {
                var ext = Path.GetExtension(obj.FatherCivilIDFront.FileName);
                if (permittedExtensions.Contains(ext))
                {
                    ImageHelper.DeleteImage(_hostEnvironment, @"Uploads\UserFamilyDetail\FatherCivilIDFront", userFamilyDetail.FatherCivilIDFront.Replace("/Uploads/UserFamilyDetail/FatherCivilIDFront/", ""));
                    userFamilyDetail.FatherCivilIDFront = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/FatherCivilIDFront", obj.FatherCivilIDFront);
                }
            }
            if (obj.MotherCivilIDFront != null)
            {
                var ext = Path.GetExtension(obj.MotherCivilIDFront.FileName);
                if (permittedExtensions.Contains(ext))
                {
                    ImageHelper.DeleteImage(_hostEnvironment, @"Uploads\UserFamilyDetail\MotherCivilIDFront", userFamilyDetail.MotherCivilIDFront.Replace("/Uploads/UserFamilyDetail/MotherCivilIDFront/", ""));
                    userFamilyDetail.MotherCivilIDFront = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/MotherCivilIDFront", obj.MotherCivilIDFront);
                }
            }
            if (obj.MotherCivilIDBack != null)
            {
                var ext = Path.GetExtension(obj.MotherCivilIDBack.FileName);
                if (permittedExtensions.Contains(ext))
                {
                    ImageHelper.DeleteImage(_hostEnvironment, @"Uploads\UserFamilyDetail\MotherCivilIDBack", userFamilyDetail.MotherCivilIDBack.Replace("/Uploads/UserFamilyDetail/MotherCivilIDBack/", ""));
                    userFamilyDetail.MotherCivilIDBack = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/MotherCivilIDBack", obj.MotherCivilIDBack);
                }
            }
            if (obj.SpousePassport != null)
            {
                var ext = Path.GetExtension(obj.SpousePassport.FileName);
                if (permittedExtensions.Contains(ext))
                {
                    ImageHelper.DeleteImage(_hostEnvironment, @"Uploads\UserFamilyDetail\SpousePassport", userFamilyDetail.SpousePassport.Replace("/Uploads/UserFamilyDetail/SpousePassport/", ""));
                    userFamilyDetail.SpousePassport = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/SpousePassport", obj.SpousePassport);
                }
            }
            if (obj.SpouseCivilIDFront != null)
            {
                var ext = Path.GetExtension(obj.SpouseCivilIDFront.FileName);
                if (permittedExtensions.Contains(ext))
                {
                    ImageHelper.DeleteImage(_hostEnvironment, @"Uploads\UserFamilyDetail\SpouseCivilIDFront", userFamilyDetail.SpouseCivilIDFront.Replace("/Uploads/UserFamilyDetail/SpouseCivilIDFront/", ""));
                    userFamilyDetail.SpouseCivilIDFront = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/SpouseCivilIDFront", obj.SpouseCivilIDFront);
                }
            }
            if (obj.SpouseCivilIDBack != null)
            {
                var ext = Path.GetExtension(obj.SpouseCivilIDBack.FileName);
                if (permittedExtensions.Contains(ext))
                {
                    ImageHelper.DeleteImage(_hostEnvironment, @"Uploads\UserFamilyDetail\SpouseCivilIDBack", userFamilyDetail.SpouseCivilIDBack.Replace("/Uploads/UserFamilyDetail/SpouseCivilIDBack/", ""));
                    userFamilyDetail.SpouseCivilIDBack = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/SpouseCivilIDBack", obj.SpouseCivilIDBack);
                }
            }
            if (obj.CompanionPassport != null)
            {
                var ext = Path.GetExtension(obj.CompanionPassport.FileName);
                if (permittedExtensions.Contains(ext))
                {
                    ImageHelper.DeleteImage(_hostEnvironment, @"Uploads\UserFamilyDetail\CompanionPassport", userFamilyDetail.CompanionPassport.Replace("/Uploads/UserFamilyDetail/CompanionPassport/", ""));
                    userFamilyDetail.CompanionPassport = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/CompanionPassport", obj.CompanionPassport);
                }
            }
            if (obj.CompanionI20 != null)
            {
                var ext = Path.GetExtension(obj.CompanionI20.FileName);
                if (permittedExtensions.Contains(ext))
                {
                    ImageHelper.DeleteImage(_hostEnvironment, @"Uploads\UserFamilyDetail\CompanionI20", userFamilyDetail.CompanionI20.Replace("/Uploads/UserFamilyDetail/CompanionI20/", ""));
                    userFamilyDetail.CompanionI20 = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/CompanionI20", obj.CompanionI20);
                }
            }

            return(userFamilyDetail);
        }
Example #2
0
        public UserFamilyDetail Add(UserFamilyDetailUpsert obj)
        {
            string[]         permittedExtensions = { ".jpg", ".jpeg", ".png", ".pdf" };
            UserFamilyDetail userFamilyDetail    = new UserFamilyDetail();
            var ext1  = Path.GetExtension(obj.ParentPassport.FileName);
            var ext2  = Path.GetExtension(obj.FatherCivilIDBack.FileName);
            var ext3  = Path.GetExtension(obj.FatherCivilIDFront.FileName);
            var ext4  = Path.GetExtension(obj.MotherCivilIDBack.FileName);
            var ext5  = Path.GetExtension(obj.MotherCivilIDFront.FileName);
            var ext6  = Path.GetExtension(obj.SpousePassport.FileName);
            var ext7  = Path.GetExtension(obj.SpouseCivilIDFront.FileName);
            var ext8  = Path.GetExtension(obj.SpouseCivilIDBack.FileName);
            var ext9  = Path.GetExtension(obj.CompanionI20.FileName);
            var ext10 = Path.GetExtension(obj.CompanionPassport.FileName);

            if ((obj.ParentPassport != null && permittedExtensions.Contains(ext1)))
            {
                userFamilyDetail.ParentPassport = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/ParentPassport", obj.ParentPassport);
            }
            if ((obj.FatherCivilIDBack != null && permittedExtensions.Contains(ext2)))
            {
                userFamilyDetail.FatherCivilIDBack = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/FatherCivilIDBack", obj.FatherCivilIDBack);
            }
            if ((obj.FatherCivilIDFront != null && permittedExtensions.Contains(ext3)))
            {
                userFamilyDetail.FatherCivilIDFront = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/FatherCivilIDFront", obj.FatherCivilIDFront);
            }
            if ((obj.MotherCivilIDBack != null && permittedExtensions.Contains(ext4)))
            {
                userFamilyDetail.MotherCivilIDBack = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/MotherCivilIDBack", obj.MotherCivilIDBack);
            }
            if ((obj.MotherCivilIDFront != null && permittedExtensions.Contains(ext5)))
            {
                userFamilyDetail.MotherCivilIDFront = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/MotherCivilIDFront", obj.MotherCivilIDFront);
            }
            if ((obj.SpousePassport != null && permittedExtensions.Contains(ext6)))
            {
                userFamilyDetail.SpousePassport = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/SpousePassport", obj.SpousePassport);
            }
            if ((obj.SpouseCivilIDFront != null && permittedExtensions.Contains(ext7)))
            {
                userFamilyDetail.SpouseCivilIDFront = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/SpouseCivilIDFront", obj.SpouseCivilIDFront);
            }
            if ((obj.SpouseCivilIDBack != null && permittedExtensions.Contains(ext8)))
            {
                userFamilyDetail.SpouseCivilIDBack = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/SpouseCivilIDBack", obj.SpouseCivilIDBack);
            }
            if ((obj.CompanionI20 != null && permittedExtensions.Contains(ext9)))
            {
                userFamilyDetail.CompanionI20 = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/CompanionI20", obj.CompanionI20);
            }
            if ((obj.CompanionPassport != null && permittedExtensions.Contains(ext10)))
            {
                userFamilyDetail.CompanionPassport = ImageHelper.UploadImageFile(_hostEnvironment, "wwwroot/Uploads/UserFamilyDetail/CompanionPassport", obj.CompanionPassport);
            }
            userFamilyDetail.UserID                = obj.UserID;
            userFamilyDetail.ParentMobileNo        = obj.ParentMobileNo;
            userFamilyDetail.FriendInUS            = obj.FriendInUS;
            userFamilyDetail.FriendAddress         = obj.FriendAddress;
            userFamilyDetail.FriendMobileNo        = obj.FriendMobileNo;
            userFamilyDetail.FamilyMemberInUS      = obj.FamilyMemberInUS;
            userFamilyDetail.FamilyMemberFirstName = obj.FamilyMemberFirstName;
            userFamilyDetail.FamilyMemberLastName  = obj.FamilyMemberLastName;
            userFamilyDetail.FamilyMemberRelation  = obj.FamilyMemberRelation;
            userFamilyDetail.FamilyMemberUSCitizen = obj.FamilyMemberUSCitizen;
            userFamilyDetail.FamilyMemberImmigrant = obj.FamilyMemberImmigrant;
            userFamilyDetail.FamilyMemberRole      = obj.FamilyMemberRole;
            userFamilyDetail.CollegeUniversity     = obj.CollegeUniversity;
            userFamilyDetail.Major            = obj.Major;
            userFamilyDetail.OrganizationName = obj.OrganizationName;
            userFamilyDetail.MonthlySalary    = obj.MonthlySalary;
            userFamilyDetail.Currency         = obj.Currency;
            userFamilyDetail.Position         = obj.Position;
            return(userFamilyDetail);
        }