public ActionResult UpdateHotel(int personId, int seminarId, HotelPostModel hotelPostModel)
{
var person = _personRepository.GetNullableById(personId);
if (person == null)
{
Message = string.Format(Messages.NotFound, "Person", personId);
return this.RedirectToAction(a => a.SiteList());
}
var reg = person.GetLatestRegistration(Site);
var seminar = SiteService.GetLatestSeminar(Site);
// check if user is registered for the current seminar
if (reg.Seminar == null || seminar == null || reg.Seminar.Id != seminar.Id)
{
Message = "User is not a part of the current seminar. Hotel info cannot be created.";
return this.RedirectToAction(a => a.AdminEdit(person.User.Id, seminarId, null));
}
// update the fields
reg.HotelCheckIn = hotelPostModel.CheckIn;
reg.HotelCheckOut = hotelPostModel.CheckOut;
reg.HotelConfirmation = hotelPostModel.Confirmation;
reg.RoomType = hotelPostModel.RoomType;
reg.HotelComments = hotelPostModel.Comments;
_eventService.HotelUpdate(person, Site);
// save
_seminarPersonRepository.EnsurePersistent(reg);
// redirect into the tab
var url = Url.Action("AdminEdit", new {id = person.User.Id, seminarId = seminarId});
return Redirect(string.Format("{0}#hotel", url));
}