public void AddUser(DO.User newUser) { var user = DS.DataSource.UsersList.FirstOrDefault(u => u.UserName == newUser.UserName); if (user != null && !newUser.IsDeleted) { throw new DO.BadUsernameException(newUser.UserName, "Duplicate user username"); } DS.DataSource.UsersList.Add(newUser.Clone()); }
public void AddUser(DO.User newUser) { var userList = XmlTools.LoadListFromXMLSerializer <DO.User>(usersPath); var user = userList.FirstOrDefault(u => u.UserName == newUser.UserName); if (user != null && !newUser.IsDeleted) { throw new DO.BadUsernameException(newUser.UserName, "Duplicate user username"); } userList.Add(newUser); XmlTools.SaveListToXMLSerializer(userList, usersPath); }
public BO.User GetUser(string userName) { DO.User userDO = null; try { userDO = dl.GetUser(userName); } catch (DO.BadUserNameException ex) { throw new BO.BadUserNameException(ex.Message, ex); } return(UserDoBoAdapter(userDO)); }
public void CreateUser(string userName, string password, int permission) { string exception = ""; bool foundException = false; try { valid.UserNameExist(userName); } catch (Exception ex) { exception += ex.Message; foundException = true; } try { valid.GoodString(userName); } catch (Exception ex) { exception += ex.Message; foundException = true; } try { valid.GoodPassword(password); } catch (Exception ex) { exception += ex.Message; foundException = true; } try { valid.GoodPermission(permission); } catch (Exception ex) { exception += ex.Message; foundException = true; } if (foundException) { throw new Exception(exception); } User userBO = new User(userName, password, permission); DO.User userDO = userBO.GetPropertiesFrom <DO.User, BO.User>(); dal.CreateUser(userDO); }
public void UpdateUser(DO.User user) { var findUser = DS.DataSource.UsersList.Find(u => u.UserName == user.UserName); if (findUser != null && !findUser.IsDeleted) { DS.DataSource.UsersList.Remove(findUser); DS.DataSource.UsersList.Add(user); } else { throw new DO.BadUsernameException(user.UserName, $"User not found {user.UserName}"); } }
public void UpdateUser(DO.User user) { var userList = XmlTools.LoadListFromXMLSerializer <DO.User>(usersPath); var findUser = userList.Find(u => u.UserName == user.UserName); if (findUser != null && !findUser.IsDeleted) { userList.Remove(findUser); userList.Add(user); XmlTools.SaveListToXMLSerializer(userList, usersPath); } else { throw new DO.BadUsernameException(user.UserName, $"User not found {user.UserName}"); } }
BO.User UserDoBoAdapter(DO.User userDO) { BO.User userBO = new BO.User(); userDO.CopyPropertiesTo(userBO); return(userBO); }
DO.User UserBoDoAdapter(BO.User userBO) { DO.User userDO = new DO.User(); userBO.CopyPropertiesTo(userDO); return(userDO); }