Exemple #1
0
        public IEnumerable <GalleryShortViewModel> GetAllGalleries()
        {
            var galleries = _galleryService.GetAll()
                            .OrderByDescending(x => x.Id)
                            .ToList();

            var model = Mapper.Map <IList <Gallery>, IList <GalleryShortViewModel> >(galleries);

            return(model);
        }
Exemple #2
0
        public ActionResult <GalleryVM> GetGalleryById(int id)
        {
            IQueryable <Gallery> galleryList = _service.GetAll(s => s.Images);
            Gallery   gallerySearch          = galleryList.FirstOrDefault(s => s.Id == id);
            GalleryVM rtnGallery             = null;

            if (gallerySearch != null)
            {
                rtnGallery = _mapper.Map <GalleryVM>(gallerySearch);
                return(Ok(rtnGallery));
            }
            else
            {
                return(NotFound(rtnGallery));
            }
        }
        public IHttpActionResult Get()
        {
            var galleries = Mapper.Map <IEnumerable <Gallery>,
                                        IEnumerable <GalleryBindingModel> >(_galleryService.GetAll());

            return(Ok(galleries.ToList()));
        }
Exemple #4
0
        public IActionResult GetAll()
        {
            var result = galleryManager.GetAll();

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
        public IActionResult Index()
        {
            AdminIndexViewModel model = new AdminIndexViewModel
            {
                CategoryCount = _categoryImageService.GetAll().Data.Count,
                GalleryCount  = _galleryService.GetAll().Data.Count,
                PageCount     = _pageService.GetAll().Data.Count,
                SlideCount    = _sliderService.GetAll().Data.Count,
                SocialCount   = _socialService.GetAll().Data.Count
            };

            return(View(model));
        }
        public async Task <IActionResult> Get(int itemCount = 24)
        {
            var galleryResponseList = await _galleryService.GetAll();

            return(Ok(galleryResponseList));
        }
 // GET: Admin/Gallery
 public ActionResult Index()
 {
     return(View(ModelMapper.ConvertToGetViewModel(_galleryService.GetAll())));
 }
        public ActionResult <IEnumerable <AccountVM> > GetAllAccount([FromQuery] AccountSM account, bool withRateScore, bool getNewFirst, int pageSize = 20, int pageIndex = 1)
        {
            try
            {
                IQueryable <Account> accountList = _accountService.GetAll(
                    s => s.Services,
                    s => s.Gallery.Images,
                    _ => _.Addresses
                    );

                if (getNewFirst)
                {
                    accountList = accountList.Where(_ => _.Role == "WORKER");
                    if (!string.IsNullOrEmpty(account.DisplayName))
                    {
                        accountList = accountList.Where(_ => _.DisplayName.Contains(account.DisplayName));
                    }
                    var result = _pagingSupport.From(accountList)
                                 .GetRange(pageIndex, pageSize, s => s.Status)
                                 .Paginate <AccountNewFirstVM>();
                    return(Ok(result));
                }

                if (!string.IsNullOrEmpty(account.Email))
                {
                    accountList = accountList.Where(s => s.Email.Contains(account.Email));
                }
                if (!string.IsNullOrEmpty(account.DisplayName))
                {
                    accountList = accountList.Where(s => s.DisplayName.Contains(account.DisplayName));
                }
                if (!string.IsNullOrEmpty(account.Phone))
                {
                    accountList = accountList.Where(s => s.Phone.Contains(account.Phone));
                }
                if (!string.IsNullOrEmpty(account.Role))
                {
                    accountList = accountList.Where(s => s.Role.Contains(account.Role));
                }
                if (!string.IsNullOrEmpty(account.Status))
                {
                    accountList = accountList.Where(s => s.Status.Contains(account.Status));
                }

                if (account.GalleryId != 0)
                {
                    accountList = accountList.Where(s => s.GalleryId == account.GalleryId);
                }


                if (account.IsBeautyArtist != false)
                {
                    accountList = accountList.Where(s => s.IsBeautyArtist == true);
                }

                if (pageSize == 0)
                {
                    pageSize = 20;
                }

                if (pageIndex == 0)
                {
                    pageIndex = 1;
                }


                var pagedModel = _pagingSupport.From(accountList)
                                 .GetRange(pageIndex, pageSize, s => s.Id)
                                 .Paginate <AccountVM>();


                if (withRateScore)
                {
                    pagedModel.Content = pagedModel.Content.AsEnumerable().Select <AccountVM, AccountVM>(_ => {
                        var rating                = _feedBackService.GetRateScoreByAccount(_.Id);
                        _.RateScore               = rating[0];
                        _.TotalFeedback           = (int)rating[1];
                        List <ServiceVM> services = new List <ServiceVM>();
                        foreach (ServiceVM service in _.Services)
                        {
                            Gallery gallery = _galleryService
                                              .GetAll(_ => _.Images)
                                              .Where(_ => _.Id == service.GalleryId).FirstOrDefault();
                            GalleryVM galleryVM = _mapper.Map <GalleryVM>(gallery);
                            service.Gallery     = galleryVM;
                            services.Add(service);
                        }
                        _.Services = services;
                        return(_);
                    }).AsQueryable();
                }


                return(Ok(pagedModel));
            }
            catch (Exception e)
            {
                return(NotFound(e));
            }
        }