public async Task <RatingParameters> SetRating(RatingParameters rating) { var temp = await repo.GetOneEnterprise(rating.EnterpriseId); var car = await repo2.GetOneCar(rating.EnterpriseId, rating.CarId); var rating1 = new EnterpriseRating(); var rating2 = new CarRating(); rating1.Rating = rating.EnterpriseRating; rating2.Rating = rating.CarRating; temp.Rating.Add(rating1); car.Ratings.Add(rating2); try { await unitOfWork.CompleteAsync(); } catch { return(null); } return(rating); }
public async Task <IActionResult> SetRating(RatingParameters rating) { if (ModelState.IsValid) { var temp = await enterpriseService.SetRating(rating); if (temp != null) { return(Ok(temp)); } else { return(BadRequest(new { Message = "Something went wrong. Please, try again later." })); } } else { return(BadRequest(new { Message = "Invalid parameters supplied." })); } }