示例#1
0
        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));
        }
示例#2
0
        public async Task <IActionResult> CreateExhibition(string Id)
        {
            Member member = await MemberRepository.GetMember(Id);

            var art     = ArtRepository.GetArtFromExhibit(member);
            var exhibit = ArtRepository.GetExhibitId(member);

            ProfileViewModel = new ProfileViewModel(member, art, exhibit);
            return(View(ProfileViewModel));
        }