public static int CreateUserPref(int userId, int categoryId) { try { using (couponEntities2 ce = new couponEntities2()) { User_Prefrences userPrefrences = new User_Prefrences { Users_Id = userId, category = categoryId }; ce.User_Prefrences.Add(userPrefrences); ce.SaveChanges(); return(userPrefrences.Id); } } catch (Exception) { return(-1); } }
public static bool UpdateUserPref(User_Prefrences userPrefrences) { try { using (couponEntities2 ce = new couponEntities2()) { var result = ce.User_Prefrences.SingleOrDefault(b => b.Id == userPrefrences.Id); if (result != null) { result.Users_Id = userPrefrences.Users_Id; result.category = userPrefrences.category; result.Costumer = userPrefrences.Costumer; ce.SaveChanges(); } } } catch (Exception) { return(false); } return(true); }