Ejemplo n.º 1
0
 public void Add(User user)
 {
     using (var context = new SsoModel())
     {
         var curentUser =
             context.SsoUsers.SingleOrDefault(
                 u => u.Name.ToLower() == user.Name.ToLower() && u.SsoId == user.SsoId);
         if (curentUser != null) throw ExceptionHelper.Conflict("User is already exist");
         context.SsoUsers.Add((SsoUser) user);
         context.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 public void Add(User user)
 {
     UpdateStore(store =>
     {
         if (
             store.Users.SingleOrDefault(
                 u =>
                     string.Equals(u.Name, user.Name, StringComparison.CurrentCultureIgnoreCase) &&
                     u.SsoId == user.SsoId) != null)
             throw ExceptionHelper.Conflict("User is already exist");
         if (store.Users.SingleOrDefault(u => u.AuthKey == user.AuthKey || u.Token == user.Token) != null)
             throw ExceptionHelper.BadRequest("User is not correct");
         store.Users = new List<User>(store.Users) {user}.ToArray();
     });
 }