public void AddFavorites(int UserId, Models.AddFavoritesRequest addFavoritesRequest) { foreach (var favorit in addFavoritesRequest.Favorites) { _gitAPIManager.FavoritseUsers.Add(new Entities.FavoritesUsers() { UserId = UserId, Favorite = favorit }); _gitAPIManager.SaveChanges(); } }
public User CreateUser(string UserName, string Password) { if (_gitAPIManager.Users.FirstOrDefault(x => x.UserName == UserName) != null) { throw new Exception("User already exist"); } var user = new User { UserName = UserName, Password = HashHelper.ComputeHash(Password) }; _gitAPIManager.Users.Add(user); _gitAPIManager.SaveChanges(); return(user); }