Exemplo n.º 1
0
        public ActionResult Index()
        {
            //var exhibits = new List<Exhibit>()
            //{
            //    new Exhibit()
            //    {
            //        Id = 1,
            //        Name = "Mona Lisa",
            //        Description = "Oil Painting",
            //        Type = "Painting",
            //        Created = DateTime.MinValue
            //    },
            //    new Exhibit()
            //    {
            //        Id = 2,
            //        Name = "Picasso",
            //        Description = "Water Color",
            //        Type = "Painting",
            //        Created = DateTime.MinValue
            //    }

            //};

            var exhibitViewModel = new ExhibitViewModel()
            {
                Heading  = "Current exhibits",
                Exhibits = _service.Get()
            };

            return(View("Index", exhibitViewModel));
        }
Exemplo n.º 2
0
        public IActionResult SetCoral()
        {
            var i = new ExhibitViewModel();

            i.ExhibitId = 1;
            return(View(i));
        }
Exemplo n.º 3
0
        public async Task <string> CreateAsync(string hallId, string standId, ExhibitViewModel entity)
        {
            if (entity.Photos != null)
            {
                foreach (var photo in entity.Photos)
                {
                    ObjectId id = await _gridFS.UploadFromBytesAsync(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fffffff"), photo?.Photo);

                    photo.Id    = id.ToString();
                    photo.Photo = null;
                }
            }
            else
            {
                entity.Photos = new List <PhotoInfo>();
            }

            var filter = Builders <HallViewModel> .Filter.And(
                Builders <HallViewModel> .Filter.Where(hall => hall.Id.Equals(hallId)),
                Builders <HallViewModel> .Filter.Eq("Stands.Id", standId));

            entity.Id = ObjectId.GenerateNewId().ToString();
            var update = Builders <HallViewModel> .Update.Push("Stands.$.Exhibits", entity);

            await _halls.FindOneAndUpdateAsync(filter, update);

            return(entity.Id);
        }
Exemplo n.º 4
0
        public IActionResult SetDeep()
        {
            var i = new ExhibitViewModel();

            i.ExhibitId = 0;
            return(View(i));
        }
Exemplo n.º 5
0
        public ActionResult Index()
        {
            var exhibitViewModel = new ExhibitViewModel()
            {
                Heading  = "Current exhibits",
                Exhibits = _query.Get()
            };

            return(View("Index", exhibitViewModel));
        }
        public async Task <IActionResult> Index()
        {
            List <Exhibit> exhibits = await artRepository.GetExhibits();

            var artworks = await artRepository.GetAllArtToExhibitions();

            List <Artwork> listOfArt = artworks.ToList();

            listOfArt = artworks.ToList();
            ExhibitViewModel viewModel = new ExhibitViewModel(exhibits, listOfArt);

            return(View(viewModel));
        }
Exemplo n.º 7
0
        public async Task UpdateAsync(string hallId, string standId, string id, ExhibitViewModel entity)
        {
            for (int i = 0; i < entity.Photos?.Count; i++)
            {
                if (!string.IsNullOrEmpty(entity.Photos[i]?.Id))
                {
                    await _gridFS.DeleteAsync(ObjectId.Parse(entity.Photos[i].Id));
                }
                if (entity.Photos[i]?.Photo != null)
                {
                    ObjectId photoId = await _gridFS.UploadFromBytesAsync(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fffffff"), entity.Photos[i].Photo);

                    entity.Photos[i].Id    = photoId.ToString();
                    entity.Photos[i].Photo = null;
                }
                else
                {
                    entity.Photos.RemoveAt(i--);
                }
            }

            int index1 = 0, index2 = 0;
            var hall = await _halls.Find(hall => hall.Id.Equals(hallId)).FirstOrDefaultAsync();

            for (int i = 0; i < hall.Stands.Count; i++)
            {
                if (hall.Stands[i].Id == standId)
                {
                    index1 = i;
                    break;
                }
            }

            for (int i = 0; i < hall.Stands[index1].Exhibits.Count; i++)
            {
                if (hall.Stands[index1].Exhibits[i].Id == id)
                {
                    index2 = i;
                    break;
                }
            }

            var arrayFilter = Builders <HallViewModel> .Filter.Where(hall => hall.Id.Equals(hallId));

            var update = Builders <HallViewModel> .Update.Set($"Stands.{index1}.Exhibits.{index2}", entity);

            await _halls.FindOneAndUpdateAsync(arrayFilter, update);
        }
Exemplo n.º 8
0
        public async Task <ExhibitViewModel> CreateAsync(ExhibitViewModel exhibit, IEnumerable <IFormFile> files, IEnumerable <string> photoDescriptionBe, IEnumerable <string> photoDescriptionEn, IEnumerable <string> photoDescriptionRu)
        {
            if (files.Count() != 0)
            {
                await _formFileToByteConverterService.ConvertAsync(files, exhibit);
            }
            if (photoDescriptionBe?.Count() != 0 && photoDescriptionBe != null)
            {
                for (int i = 0; i < photoDescriptionBe.Count(); i++)
                {
                    exhibit.Photos[i].DescriptionBe = photoDescriptionBe.ElementAt(i);
                    exhibit.Photos[i].DescriptionEn = photoDescriptionEn.ElementAt(i);
                    exhibit.Photos[i].DescriptionRu = photoDescriptionRu.ElementAt(i);
                }
            }

            return(exhibit);
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Update(
            [FromRoute] Guid exhibitId,
            [FromBody] ExhibitViewModel viewModel)
        {
            try
            {
                var exhibit = _mapper.Map <Exhibit>(viewModel);
                exhibit.Id = exhibitId;
                var userId = GetUserId();

                await _exhibitUseCases.Update(exhibit, userId);

                return(NoContent());
            }
            catch (NotFoundException e)
            {
                return(NotFound(e.Message));
            }
        }
Exemplo n.º 10
0
        public async Task <IActionResult> Add(
            [FromQuery] Guid subdivisionId,
            [FromBody] ExhibitViewModel viewModel)
        {
            try
            {
                var exhibitToAdd = _mapper.Map <Exhibit>(viewModel);
                exhibitToAdd.Subdivision = new Subdivision {
                    Id = subdivisionId
                };
                var userId = GetUserId();

                var exhibit = await _exhibitUseCases.Add(exhibitToAdd, userId);

                return(Ok(new { exhibit.Id }));
            }
            catch (BadRequestException e)
            {
                return(BadRequest(e.Message));
            }
        }
Exemplo n.º 11
0
        public ExhibitPage(Guid exhibitID)
        {
            InitializeComponent();

            viewModel = new ExhibitViewModel();
            ExhibitBase exhibitBase = ExhibitBase.GetExhibitBase();
            var         FavExhibits = exhibitBase.GetFavourites();
            Exhibit     exhibit     = exhibitBase.Exhibits.Find((e) => e.ID == exhibitID);

            viewModel.ImageSource = exhibit.ImageSource;
            // TODO: Remove other attributes apart from ID from ExhibitID
            viewModel.ExhibitID          = exhibit.ID;
            viewModel.ExhibitName        = exhibit.Name;
            viewModel.ExhibitDescription = ArtistBase.GetInstance().GetArtistBio(exhibit.Artist.Name);
            viewModel.IsFavourite        = FavExhibits.Contains(exhibit);
            BindingContext = viewModel;

            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += (s, e) =>
            {
                // Switch favourite state
                if (viewModel.IsFavourite)
                {
                    // Unfavourite item
                    viewModel.IsFavourite = false;
                    exhibitBase.RemoveFavourite(viewModel.ExhibitID);
                }
                else
                {
                    // Favourite item
                    viewModel.IsFavourite = true;
                    exhibitBase.AddFavourite(viewModel.ExhibitID);
                }
                // TODO: Do this using data binding
                image_favourite.Source = viewModel.FavImageSource;
            };
            image_favourite.GestureRecognizers.Add(tapGestureRecognizer);
        }
Exemplo n.º 12
0
        public async Task ConvertAsync(IEnumerable <IFormFile> files, ExhibitViewModel exhibit)
        {
            if (exhibit.Photos == null)
            {
                exhibit.Photos = new List <PhotoInfo>();
            }

            foreach (var photo in files)
            {
                if (photo.Length > 0)
                {
                    using (var memoryStream = new MemoryStream())
                    {
                        await photo.CopyToAsync(memoryStream);

                        exhibit.Photos.Add(new PhotoInfo()
                        {
                            Photo = memoryStream.ToArray()
                        });
                    }
                }
            }
        }
Exemplo n.º 13
0
        public IActionResult Index()
        {
            var i = new ExhibitViewModel();

            return(View(i));
        }
Exemplo n.º 14
0
        public async Task <ExhibitViewModel> EditArticleAsync(string hallId, string standId, ExhibitViewModel exhibit, IEnumerable <IFormFile> files, IEnumerable <string> ids)
        {
            var initialExhibit = await _exhibitsRepository.GetAsync(hallId, standId, exhibit.Id);

            if (initialExhibit.Photos != null)
            {
                exhibit.Photos = initialExhibit.Photos;
                foreach (var photo in exhibit.Photos)
                {
                    if (!ids.Contains(photo?.Id))
                    {
                        photo.Photo = null;
                    }
                }
            }

            if (files.Count() != 0)
            {
                await _formFileToByteConverterService.ConvertAsync(files, exhibit);
            }

            return(exhibit);
        }
Exemplo n.º 15
0
        public async Task <ExhibitViewModel> EditGalleryAsync(string hallId, string standId, ExhibitViewModel exhibit, IEnumerable <IFormFile> files, IEnumerable <string> ids, IEnumerable <string> photoDescriptionBe, IEnumerable <string> photoDescriptionEn, IEnumerable <string> photoDescriptionRu)
        {
            var initialExhibit = await _exhibitsRepository.GetAsync(hallId, standId, exhibit.Id);

            exhibit.Photos = new List <PhotoInfo>();
            int fileIndex = 0;

            for (int i = 0; i < ids.Count(); i++)
            {
                exhibit.Photos.Add(new PhotoInfo()
                {
                    DescriptionBe = photoDescriptionBe.ElementAt(i),
                    DescriptionEn = photoDescriptionEn.ElementAt(i),
                    DescriptionRu = photoDescriptionRu.ElementAt(i),
                });
                if (ids.ElementAt(i) == "0")
                {
                    using (var memoryStream = new MemoryStream())
                    {
                        await files.ElementAt(fileIndex ++).CopyToAsync(memoryStream);

                        exhibit.Photos[i].Photo = memoryStream.ToArray();
                    }
                }
                else
                {
                    exhibit.Photos[i].Id    = ids.ElementAt(i);
                    exhibit.Photos[i].Photo = initialExhibit.Photos.FirstOrDefault(p => p.Id.Equals(ids.ElementAt(i))).Photo;
                }
            }

            for (int i = 0; i < initialExhibit.Photos.Count(); i++)
            {
                if (!ids.Contains(initialExhibit.Photos[i].Id))
                {
                    exhibit.Photos.Add(new PhotoInfo()
                    {
                        Id = initialExhibit.Photos[i].Id
                    });
                }
            }

            return(exhibit);
        }
Exemplo n.º 16
0
        public async Task EditGallery(string hallId, string standId, ExhibitViewModel exhibit, IEnumerable <IFormFile> files, IEnumerable <string> ids, IEnumerable <string> photoDescriptionBe, IEnumerable <string> photoDescriptionEn, IEnumerable <string> photoDescriptionRu)
        {
            exhibit = await _exhibitsService.EditGalleryAsync(hallId, standId, exhibit, files, ids, photoDescriptionBe, photoDescriptionEn, photoDescriptionRu);

            await _exhibitsRepository.UpdateAsync(hallId, standId, exhibit.Id, exhibit);
        }
Exemplo n.º 17
0
        public async Task EditArticle(string hallId, string standId, ExhibitViewModel exhibit, IEnumerable <IFormFile> files, IEnumerable <string> ids)
        {
            exhibit = await _exhibitsService.EditArticleAsync(hallId, standId, exhibit, files, ids);

            await _exhibitsRepository.UpdateAsync(hallId, standId, exhibit.Id, exhibit);
        }
Exemplo n.º 18
0
        public async Task <string> Create(string hallId, string standId, ExhibitViewModel exhibit, IEnumerable <IFormFile> files, IEnumerable <string> photoDescriptionBe, IEnumerable <string> photoDescriptionEn, IEnumerable <string> photoDescriptionRu)
        {
            exhibit = await _exhibitsService.CreateAsync(exhibit, files, photoDescriptionBe, photoDescriptionEn, photoDescriptionRu);

            return(await _exhibitsRepository.CreateAsync(hallId, standId, exhibit));
        }