public IActionResult RateVolunteer(RateVolunteerViewModel vm) { if (!ModelState.IsValid) { return(View(vm)); } var voe = _db.VolunteersOnEvent .Include(ve => ve.Event) .FirstOrDefault(ve => ve.VolunteerOnEventId == vm.VolunteerOnEventId); if (voe == null) { return(BadRequest(ErrorMessagesProvider.VolunteerOnEventErrors.VolunteerOnEventNotExists)); } if (!voe.Event.CanModify()) { return(BadRequest()); } voe.OpinionAboutVolunteer = vm.RateContent; _db.VolunteersOnEvent.Update(voe); _db.SaveChanges(); return(RedirectToAction("PastEventDetails", new { eventId = voe.EventId })); }
public IActionResult RateVolunteer(int volunteerOnEventId) { var voe = _db.VolunteersOnEvent .Include(ve => ve.Volunteer) .Include(ve => ve.Event) .FirstOrDefault(ve => ve.VolunteerOnEventId == volunteerOnEventId); if (voe == null) { return(BadRequest(ErrorMessagesProvider.VolunteerOnEventErrors.VolunteerOnEventNotExists)); } if (!voe.Event.CanModify()) { return(BadRequest()); } var vm = new RateVolunteerViewModel { VolunteerOnEventId = voe.VolunteerOnEventId, EventId = voe.EventId, VolunteerName = voe.Volunteer.FullName, CollectedMoney = voe.AmountOfMoneyCollected, Points = voe.PointsReceived, EventName = voe.Event.Name, RateContent = voe.OpinionAboutVolunteer }; return(View(vm)); }