예제 #1
0
 public int SignUp(User user)
 {
     user.Password = this.HashPassword(user.Password);
     try
     {
         _context.User.Add(user);
         _context.SaveChanges();
         return(user.Id);
     }
     catch
     {
         return(-1);
     }
 }
예제 #2
0
 public bool AddFood(int userId, Food food)
 {
     try
     {
         food.AddedById = userId;
         food.AddedAt   = DateTime.Now;
         _context.Food.Add(food);
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }