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)); }