コード例 #1
0
ファイル: ValuesController.cs プロジェクト: M1047902/API
        public HttpResponseMessage InsertBestOftheHotel(BestOftheHotel bestOfTheHotel)
        {
            BestOftheHotel tobeInserted = new BestOftheHotel();

            tobeInserted = modelobj.BestOftheHotels.Where(m => m.HotelID == bestOfTheHotel.HotelID && m.MenuItemID == bestOfTheHotel.MenuItemID).FirstOrDefault();
            if (tobeInserted != null)
            {
                int noofSuggestions = tobeInserted.NoofSuggenstions;
                tobeInserted.NoofSuggenstions = noofSuggestions + 1;

                return(Request.CreateResponse(HttpStatusCode.OK, modelobj.SaveChanges()));
            }
            else
            {
                modelobj.BestOftheHotels.Add(bestOfTheHotel);
                return(Request.CreateResponse(HttpStatusCode.OK, modelobj.SaveChanges()));
            }
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: M1047902/API
 public ActionResult InsertBestOftheHotel(BestOftheHotel bestOfTheHotel)
 {
     modelobj.BestOftheHotels.Add(bestOfTheHotel);
     return(View(modelobj.SaveChanges()));
 }