Example #1
0
        public ReturnValue<bool> DeleteT_UserProfile(T_UserProfile iT_UserProfiles)
        {
            try
            {
                //Delete role
                //Delete all previous role
                RemoveUserRole(iT_UserProfiles.UserId);
                //Delete webpage membership
                webpages_Membership membership = _dataContext.webpages_Membership.Where(m=>m.UserId == iT_UserProfiles.UserId).SingleOrDefault();
                if(membership != null)
                {
                    _dataContext.webpages_Membership.Remove(membership);
                }

                _dataContext.SaveChanges();

                //Delete this profile
                _dataContext.T_UserProfile.Remove(iT_UserProfiles);
                _dataContext.SaveChanges();
                return new ReturnValue<bool>(true, "");
            }
            catch (Exception)
            {
                return new ReturnValue<bool>(false, "");
            }
        }
Example #2
0
 public T_UserProfile AddNewT_UserProfileAndReturn(T_UserProfile iT_UserProfiles)
 {
     //Check exist
     T_UserProfile T_UserProfilesFound = _dataContext.T_UserProfile.Where(m => m.UserName == iT_UserProfiles.UserName).SingleOrDefault();
     //Return exist T_UserProfiles
     if (T_UserProfilesFound != null) return T_UserProfilesFound;
     else
     {
         _dataContext.T_UserProfile.Add(iT_UserProfiles);
         _dataContext.SaveChanges();
         return iT_UserProfiles;
     }
 }
Example #3
0
 public ReturnValue<bool> AddNewT_UserProfile(T_UserProfile iT_UserProfiles)
 {
     if (IsExist(iT_UserProfiles)) return new ReturnValue<bool>(false, "Mục đã tồn tại");
     if (string.IsNullOrEmpty(iT_UserProfiles.UserName)) return new ReturnValue<bool>(false, "Dữ liệu không đúng");
     try
     {
         _dataContext.T_UserProfile.Add(iT_UserProfiles);
         _dataContext.SaveChanges();
         return new ReturnValue<bool>(true, "");
     }
     catch (Exception)
     {
         return new ReturnValue<bool>(false, "");
     }
 }
Example #4
0
 public ReturnValue<bool> UpdateT_UserProfile(T_UserProfile iT_UserProfiles)
 {
     if (IsExist(iT_UserProfiles)) return new ReturnValue<bool>(false, "Mục đã tồn tại");
     if (string.IsNullOrEmpty(iT_UserProfiles.UserName)) return new ReturnValue<bool>(false, "Dữ liệu không đúng");
     try
     {
         _dataContext.Entry(iT_UserProfiles).State = EntityState.Modified;
         return new ReturnValue<bool>(_dataContext.SaveChanges() > 0, "");
     }
     catch (Exception)
     {
         return new ReturnValue<bool>(false, "");
     }
 }
Example #5
0
 public bool IsExist(T_UserProfile iT_UserProfiles)
 {
     T_UserProfile T_UserProfilesFound = _dataContext.T_UserProfile.Where(m => m.UserId != iT_UserProfiles.UserId && m.UserName == iT_UserProfiles.UserName).SingleOrDefault();
     return (T_UserProfilesFound != null) ? true : false;
 }