public void Register(User user) { if (mContext.Users.GetByAuth(user.Login, user.Password) != null) throw new Exception("Пользователь с такими данными уже зарегистрирован"); user.Id = Guid.NewGuid(); mContext.Users.Add(user); mContext.SaveChanges(); }
public void Update(User user) { var dbEntity = mContext.Users.Find(user.Id); if (dbEntity != null) mContext.Entry(dbEntity).CurrentValues.SetValues(user); }
public void Add(User user) { user.Id = Guid.NewGuid(); mContext.Users.Add(user); }
public void Notificate(User user, string message) { throw new NotImplementedException(); }
private string GetSpectatorName(User spectator) { if (string.IsNullOrWhiteSpace(spectator.FirstName) && string.IsNullOrWhiteSpace(spectator.LastName)) return spectator.Login; return string.Format("{0} {1}", spectator.LastName, spectator.FirstName); }
public MembershipUser CreateUser(string userName, string password, string email, string firstName, string lastName) { var membershipUser = GetUser(userName, false); if (membershipUser == null) { try { var user = new User() { Login = userName, Password = Crypto.HashPassword(password), FirstName = firstName, LastName = lastName, Email = email, CreationDate = DateTime.UtcNow, }; UserServiceHelper.ProcessRequest(a => a.Register(user)); membershipUser = GetUser(userName, false); return membershipUser; } catch { return null; } } return null; }