{ public bool CreateRate(RateCreate model) { Rate rate = new Rate { Score = model.Score, EateryId = model.EateryId, }; using (var e = new ApplicationDbContext()) { e.Rates.Add(rate); return(e.SaveChanges() == 1); } }
public IHttpActionResult Post(RateCreate rate) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateRateService(); if (!service.CreateRate(rate)) { return(InternalServerError()); } return(Ok()); }
public bool RateASong(RateCreate model) { SongRating addRate = new SongRating(); addRate.SongId = model.SongId; addRate.SongRate = model.MyRating; using (var context = new ApplicationDbContext()) { context.SongRatings.Add(addRate); context.SaveChanges(); SongServices myRate = new SongServices(); myRate.AverageRating(model.SongId); return(context.SaveChanges() == 0); }; }
public IHttpActionResult PostRating(RateCreate songId) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } RateServices service = new RateServices(); if (!service.RateASong(songId)) { return(InternalServerError()); } return(Ok()); }