public async Task <IActionResult> UploadExhibition([Bind("Exhibit, Member")] ProfileViewModel profileView) { var startDate = Request.Form["trip-start"]; var stopDate = Request.Form["trip-stop"]; profileView.Exhibit.StartDate = DateTime.Parse(startDate); profileView.Exhibit.StopDate = DateTime.Parse(stopDate); bool exist = ArtRepository.CheckIfIdExists(profileView.Member); try { if (ModelState.IsValid) { if (exist == true) { await ArtRepository.UpdateExhibition(profileView.Member, profileView.Exhibit); } } } catch (Exception ex) { return(View("Error", ex)); } string Id = profileView.Member.MemberId; return(RedirectToAction($"Index", new { Id })); }
public async Task <IActionResult> CreateExhibition([Bind("Artwork")] ProfileViewModel profileView, string Id) { var selected = Request.Form.Files[0]; var category = Request.Form["category"]; profileView.Artwork.Type = category; profileView.Artwork.ImageFile = selected; profileView.Artwork.ImageName = selected.FileName; Member member = await MemberRepository.GetMember(Id); bool exist = ArtRepository.CheckIfIdExists(member); try { if (ModelState.IsValid) { if (exist == true) { Exhibit exhibit = ArtRepository.GetExhibitId(member); var artwork = await ArtRepository.AddArtWithExistingExhibitId(_hostEnvironment, profileView.Artwork, member, exhibit); } else if (exist == false) { Exhibit exhibit = await ArtRepository.CreateExhibit(member); var artwork = await ArtRepository.AddArt(_hostEnvironment, profileView.Artwork, member, exhibit); } } } catch (Exception ex) { return(View("Error", ex)); } return(Json(profileView.Artwork.ImageName)); }