/// <summary> /// LogedIn user changes his password /// </summary> /// <param name="oldPassword"></param> /// <param name="newPassword"></param> /// <returns></returns> public bool ChangePassword(string oldPassword, string newPassword) { using (var entityConntext = new GeoViewerEntities()) { if (AppContext.Current.LogedInUser.Password != oldPassword.GetMd5Hash()) throw new Exception(Properties.Resources.Error_OldPasswordNotMatch); AppContext.Current.LogedInUser.Password = newPassword.GetMd5Hash(); entityConntext.AttachUpdatedObject(AppContext.Current.LogedInUser); return entityConntext.SaveChanges() > 0; } }
public bool UpdateGroup(Group obj) { using (var entityConntext = new GeoViewerEntities()) { SecurityBLL.Current.CheckPermissionThrowException(new string[] { SecurityBLL.ROLE_VIEWS_EDIT, SecurityBLL.ROLE_VIEWS_MANAGE }); ValidateGroup(obj); obj.LastEditedDate = DateTime.Now; obj.LastEditedUser = AppContext.Current.LogedInUser.Username; entityConntext.AttachUpdatedObject(obj); return entityConntext.SaveChanges() > 0; } }
public bool Update(Logger obj) { bool result = false; using (var entityConntext = new GeoViewerEntities()) { SecurityBLL.Current.CheckPermissionThrowException(new[] { SecurityBLL.ROLE_DATA_EDIT, SecurityBLL.ROLE_DATA_MANAGE }); Validate(obj); obj.LastEditedDate = DateTime.Now; obj.LastEditedUser = AppContext.Current.LogedInUser.Username; entityConntext.AttachUpdatedObject(obj); result = entityConntext.SaveChanges() > 0; } if (result) { if (!obj.AutomaticReadData) { ReaderThreadManager.Current.RemoveThread(obj); } else { ReaderThreadManager.Current.SaveThread(obj); } } return result; }
public bool Update(Project obj) { using (var entityConntext = new GeoViewerEntities()) { SecurityBLL.Current.CheckPermissionThrowException(new string[] { SecurityBLL.ROLE_DATA_EDIT, SecurityBLL.ROLE_DATA_MANAGE }); Validate(obj); entityConntext.AttachUpdatedObject(obj); return entityConntext.SaveChanges() > 0; } }
public bool Delete(Account account) { using (var entityConntext = new GeoViewerEntities()) { SecurityBLL.Current.CheckPermissionThrowException(SecurityBLL.ROLE_ACCOUNT_MANAGE); // Check RootAdmin if (account.Username == "RootAdmin") throw new Exception(Resources.Error_CannotDeleteRootAdmin); entityConntext.AttachUpdatedObject(account, EntityState.Deleted); return entityConntext.SaveChanges() > 0; } }
/// <summary> /// Admin change password of an user /// </summary> /// <param name="user"></param> /// <param name="newPassword"></param> /// <returns></returns> public bool ChangePassword(Account user, string newPassword) { using (var entityConntext = new GeoViewerEntities()) { SecurityBLL.Current.CheckPermissionThrowException(new string[] { SecurityBLL.ROLE_ACCOUNT_EDIT, SecurityBLL.ROLE_ACCOUNT_MANAGE }); user.Password = newPassword.GetMd5Hash(); entityConntext.AttachUpdatedObject(user); return entityConntext.SaveChanges() > 0; } }
public bool Update(Account account) { using (var entityConntext = new GeoViewerEntities()) { SecurityBLL.Current.CheckPermissionThrowException(new string[] { SecurityBLL.ROLE_ACCOUNT_MANAGE, SecurityBLL.ROLE_ACCOUNT_EDIT }); Validate(account); int count = entityConntext.Accounts.Count( ent => ent.Username != account.Username && ent.Email == account.Email); if (count > 0) { throw new Exception(Resources.Error_Account_EmailIsUsed); } entityConntext.AttachUpdatedObject(account); return entityConntext.SaveChanges() > 0; } }