public MA_PROFILE_FUNCTIONAL CreateProfileFunction(SessionInfo sessioninfo, MA_PROFILE_FUNCTIONAL profilefunction) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { if (ValidateProfileFunction(profilefunction)) { unitOfWork.MA_PROFILE_FUNCTIONALRepository.Add(profilefunction); unitOfWork.Commit(); } else throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA); } return profilefunction; }
public MA_PROFILE_FUNCTIONAL UpdateProfileFunction(SessionInfo sessioninfo, MA_PROFILE_FUNCTIONAL profilefunction) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { var checkDuplicate = unitOfWork.MA_PROFILE_FUNCTIONALRepository.GetAll().FirstOrDefault(p => p.USER_PROFILE_ID == profilefunction.USER_PROFILE_ID && p.FUNCTIONAL_ID == profilefunction.FUNCTIONAL_ID && p.ID != profilefunction.ID); if (checkDuplicate != null) throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA); var foundprofilefunction = unitOfWork.MA_PROFILE_FUNCTIONALRepository.All().FirstOrDefault(p => p.ID == profilefunction.ID); if (foundprofilefunction == null) throw this.CreateException(new Exception(), Messages.DATA_NOT_FOUND); else { foundprofilefunction.ID = profilefunction.ID; foundprofilefunction.ISAPPROVABLE = profilefunction.ISAPPROVABLE; foundprofilefunction.ISREADABLE = profilefunction.ISREADABLE; foundprofilefunction.ISWRITABLE = profilefunction.ISWRITABLE; foundprofilefunction.USER_PROFILE_ID = profilefunction.USER_PROFILE_ID; foundprofilefunction.FUNCTIONAL_ID = profilefunction.FUNCTIONAL_ID; unitOfWork.Commit(); } } return profilefunction; }
private bool ValidateProfileFunction(MA_PROFILE_FUNCTIONAL data) { List<MA_PROFILE_FUNCTIONAL> oldData = null; using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { oldData = unitOfWork.MA_PROFILE_FUNCTIONALRepository.GetAll().Where(t => t.FUNCTIONAL_ID == data.FUNCTIONAL_ID && t.USER_PROFILE_ID == data.USER_PROFILE_ID).ToList(); if (oldData.Count > 0) return false; else return true; } }
public static object Update(MA_PROFILE_FUNCTIONAL record) { return ProfileFunctionalUIP.Update(SessionInfo, record); }