public IActionResult Details()
        {
            int      userId = Autentification.GetLoggedUser(HttpContext).Id;
            Museums  m      = museumRepository.GetMuseumByAccId(userId);
            MuseumVM model  = new MuseumVM()
            {
                Id               = m.Id,
                Name             = m.Name,
                UserId           = m.UserId,
                Username         = m.User.Username,
                PasswordHash     = m.User.PasswordHash,
                PasswordSalt     = m.User.PasswordSalt,
                RegistrationDate = m.User.RegistrationDate.ToString("dd/MM/yyyy"),
                MuseumType       = m.MuseumType.Name,
                MuseumTypeId     = m.MuseumTypeId,
                Year             = m.OpeningYear,
                QrScanning       = m.QrScanning,
                TicketSelling    = m.OnlineTickets,
                Description      = m.Description,
                Email            = m.Email,
                Phone            = m.Phone,
                Address          = m.Address,
                Latitude         = m.Latitude,
                Longitude        = m.Longitude,
                Images           = imageRepository.GetMuseumImages(m.Id),
                WorkingHour      = workingHoursRepository.GetWorkingHours(m.Id),
                MuseumTypes      = null
            };

            return(View("Details", model));
        }
Example #2
0
        public IActionResult Details(int id)
        {
            Museums  m     = museumRepository.GetMuseum(id);
            MuseumVM model = new MuseumVM();

            model.Id          = m.Id;
            model.Address     = m.Address;
            model.Description = m.Description;
            model.Email       = m.Email;
            if (model.Image != null)
            {
                model.ImageId = model.Image.Id;
            }

            model.Images        = imageRepository.GetMuseumImages(id);
            model.Latitude      = m.Latitude;
            model.Longitude     = m.Longitude;
            model.Image         = imageRepository.GetMuseumImage(m.Id);
            model.Name          = m.Name;
            model.OpeningYear   = m.OpeningYear;
            model.Phone         = m.Phone;
            model.TicketSelling = m.OnlineTickets;
            model.Type          = m.MuseumType.Name;
            model.UserId        = m.UserId;
            List <Artworks> artworks = artworkRepository.GetArtworksByMuseum(m.Id);

            model.Artworks = new List <ArtworkVM>();
            foreach (Artworks a in artworks)
            {
                ArtworkVM vm = new ArtworkVM();
                vm.Artist        = a.Artist.Name;
                vm.ArtworkType   = a.ArtworkType.Name;
                vm.ArtworkTypeId = a.ArtworkTypeId;
                vm.Country       = a.Country.Name;
                vm.Id            = a.Id;
                vm.Image         = imageRepository.GetArtworkImage(a.Id);
                if (vm.Image != null)
                {
                    vm.ImageId = vm.Image.Id;
                }
                vm.Name     = a.Name;
                vm.MuseumId = a.MuseumId;
                model.Artworks.Add(vm);
            }

            List <News> news = newsRepository.GetNews(m.Id);

            model.News = new List <NewsVM>();
            foreach (News x in news)
            {
                NewsVM n = new NewsVM();
                n.Id    = x.Id;
                n.Date  = x.Date;
                n.Image = imageRepository.GetNewsImage(x.Id);
                if (n.Image != null)
                {
                    n.ImageId = n.Image.Id;
                }
                n.Museum   = x.Museum.Name;
                n.Subtitle = x.SubTitle;
                n.Text     = x.Text;
                n.Title    = x.Title;
                model.News.Add(n);
            }
            model.Collections     = collectionRepository.GetCollections(m.Id);
            model.Events          = eventRepository.GetEvents(m.Id);
            model.TicketTypes     = tickettypeRepository.GetTicketTypes(m.Id);
            model.WorkingHours    = workinghoursRepository.GetWorkingHours(m.Id);
            model.Review          = new Reviews();
            model.Review.MuseumId = m.Id;
            return(View("Details", model));
        }
Example #3
0
        public IActionResult Save(WorkingHourVM model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Add", model));
            }

            IEnumerable <WorkingHours> workingHours = workinghourRepository.GetWorkingHours(model.MuseumId);

            if (model.Monday)
            {
                WorkingHours wh = new WorkingHours();
                wh.MuseumId  = model.MuseumId;
                wh.OpenTime  = model.startTime;
                wh.CloseTime = model.endTime;
                wh.Day       = 1;
                if (workingHours.Where(x => x.Day == 1).Count() != 0)
                {
                    workinghourRepository.UpdateHours(wh);
                }
                else
                {
                    workinghourRepository.InsertHours(wh);
                }
            }

            if (model.Tuesday)
            {
                WorkingHours wh = new WorkingHours();
                wh.MuseumId  = model.MuseumId;
                wh.OpenTime  = model.startTime;
                wh.CloseTime = model.endTime;
                wh.Day       = 2;
                if (workingHours.Where(x => x.Day == 2).Count() != 0)
                {
                    workinghourRepository.UpdateHours(wh);
                }
                else
                {
                    workinghourRepository.InsertHours(wh);
                }
            }

            if (model.Wednesday)
            {
                WorkingHours wh = new WorkingHours();
                wh.MuseumId  = model.MuseumId;
                wh.OpenTime  = model.startTime;
                wh.CloseTime = model.endTime;
                wh.Day       = 3;
                if (workingHours.Where(x => x.Day == 3).Count() != 0)
                {
                    workinghourRepository.UpdateHours(wh);
                }
                else
                {
                    workinghourRepository.InsertHours(wh);
                }
            }

            if (model.Thursday)
            {
                WorkingHours wh = new WorkingHours();
                wh.MuseumId  = model.MuseumId;
                wh.OpenTime  = model.startTime;
                wh.CloseTime = model.endTime;
                wh.Day       = 4;
                if (workingHours.Where(x => x.Day == 4).Count() != 0)
                {
                    workinghourRepository.UpdateHours(wh);
                }
                else
                {
                    workinghourRepository.InsertHours(wh);
                }
            }

            if (model.Friday)
            {
                WorkingHours wh = new WorkingHours();
                wh.MuseumId  = model.MuseumId;
                wh.OpenTime  = model.startTime;
                wh.CloseTime = model.endTime;
                wh.Day       = 5;
                if (workingHours.Where(x => x.Day == 5).Count() != 0)
                {
                    workinghourRepository.UpdateHours(wh);
                }
                else
                {
                    workinghourRepository.InsertHours(wh);
                }
            }

            if (model.Saturday)
            {
                WorkingHours wh = new WorkingHours();
                wh.MuseumId  = model.MuseumId;
                wh.OpenTime  = model.startTime;
                wh.CloseTime = model.endTime;
                wh.Day       = 6;
                if (workingHours.Where(x => x.Day == 6).Count() != 0)
                {
                    workinghourRepository.UpdateHours(wh);
                }
                else
                {
                    workinghourRepository.InsertHours(wh);
                }
            }

            if (model.Sunday)
            {
                WorkingHours wh = new WorkingHours();
                wh.MuseumId  = model.MuseumId;
                wh.OpenTime  = model.startTime;
                wh.CloseTime = model.endTime;
                wh.Day       = 7;
                if (workingHours.Where(x => x.Day == 7).Count() != 0)
                {
                    workinghourRepository.UpdateHours(wh);
                }
                else
                {
                    workinghourRepository.InsertHours(wh);
                }
            }

            workinghourRepository.Save();

            return(RedirectToAction("GetMuseum", "Museum", new { id = model.MuseumId }));
        }