public MA_USER_PROFILE UpdateUserProfile(SessionInfo sessioninfo, MA_USER_PROFILE userprofile)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_USER_PROFILERepository.GetAll().FirstOrDefault(p => p.LABEL.ToLower().Equals(userprofile.LABEL.ToLower()) && p.ID != userprofile.ID);
                if (checkDuplicate != null)
                    throw this.CreateException(new Exception(), "Profile is duplicated");

                var founduserprofile = unitOfWork.MA_USER_PROFILERepository.All().FirstOrDefault(p => p.ID == userprofile.ID);
                if (founduserprofile == null)
                    throw this.CreateException(new Exception(), "Data not found!");
                else
                {

                    founduserprofile.ID = userprofile.ID;
                    founduserprofile.LABEL = userprofile.LABEL;
                    founduserprofile.ISACTIVE = userprofile.ISACTIVE;

                    unitOfWork.Commit();

                }
            }

            return userprofile;
        }
        public MA_USER_PROFILE CreateUserProfile(SessionInfo sessioninfo, MA_USER_PROFILE userprofile)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_USER_PROFILERepository.GetAll().FirstOrDefault(p => p.LABEL.ToLower().Equals(userprofile.LABEL.ToLower()));
                if (checkDuplicate != null)
                    throw this.CreateException(new Exception(), "Profile is duplicated");

                unitOfWork.MA_USER_PROFILERepository.Add(userprofile);
                unitOfWork.Commit();
            }

            return userprofile;
        }
Beispiel #3
0
 public static object UpdateProfile(SessionInfo sessioninfo, MA_USER_PROFILE record)
 {
     try
     {
         ProfileBusiness _profileBusiness = new ProfileBusiness();
         record.ID = record.ID;
         record.LABEL = record.LABEL;
         record.ISACTIVE = record.ISACTIVE;
         var addedStudent = _profileBusiness.UpdateUserProfile(sessioninfo, record);
         return new { Result = "OK" };
     }
     catch (Exception ex)
     {
         return new { Result = "ERROR", Message = ex.Message };
     }
 }
 public static object Update(MA_USER_PROFILE record)
 {
     return ProfileUIP.UpdateProfile(SessionInfo, record);
 }