public async Task <IActionResult> MeetingEdit(int meetingId) { var userId = _userManager.GetUserId(User); var checkOwnership = await _meetingQuery.CheckMeetingOwnerAsync(meetingId, userId); if (checkOwnership == false) { return(RedirectPermanent(Url.Action("Index", "MeetingInfo"))); } var meeting = await _meetingQuery.GetMeetingByIdAsync(meetingId); var meetingCategories = await _meetingQuery .GetMeetingCategoriesAsync(); var model = new MeetingEditViewModel { Id = meeting.Id, Name = meeting.Name, Description = meeting.Description, MeetingCategoryId = meeting.MeetingCategoryId, MeetingCategories = meetingCategories, MeetingDate = meeting.MeetingDate, CurrentPhotoPath = meeting.PhotoPath, CityId = meeting.CitiesId }; return(View(model)); }
public async Task <IActionResult> MeetingEdit(MeetingEditViewModel model) { if (!ModelState.IsValid) { return(View(model)); } string photoPath = null; if (model.PhotoSource != null) { photoPath = await _fileService .UpdateImageAsync(model.CurrentPhotoPath, model.PhotoSource); } var userId = _userManager.GetUserId(User); var meeting = new Meeting { Id = model.Id, Name = model.Name, Description = model.Description, MeetingCategoryId = model.MeetingCategoryId, MeetingDate = model.MeetingDate, PhotoPath = photoPath ?? model.CurrentPhotoPath, UserId = userId, CitiesId = model.CityId }; var result = await _meetingManager.EditMeetingAsync(meeting); if (result == OperationResult.Failed) { return(View(model)); } return(RedirectPermanent(Url.Action("MeetingsOwn", "MeetingInfo"))); }