コード例 #1
0
        public int?AddIndex(Index_descriptionViewModel descriptionViewModel)
        {
            Index_description model = _mapper.Map <Index_description>(descriptionViewModel);

            model.IsActive = true;
            dbContext.index_Descriptions.Add(model);
            var result = this.dbContext.SaveChanges();

            return(result);
        }
コード例 #2
0
        public DashboardViewModel getDashBoard(bool isAdmin)
        {
            Index_description result1 = new Index_description();
            List <Carousel>   result2 = new List <Carousel>();

            result1 = this.dbContext.index_Descriptions.FirstOrDefault(x => x.IsActive == true);
            result2 = this.dbContext.carousels.Where(x => x.IsActive == true).ToList();

            return(new DashboardViewModel
            {
                activeArtist = _Mapper.Map <Index_descriptionViewModel>(result1),
                Carousels = _Mapper.Map <List <CarouselViewModel> >(result2)
            });
        }
コード例 #3
0
        public Index_descriptionViewModel getIndexById(bool isAdmin, int id)
        {
            Index_description result = new Index_description();

            if (isAdmin)
            {
                result = this.dbContext.index_Descriptions.FirstOrDefault(x => x.Sno == id);
            }
            else
            {
                result = this.dbContext.index_Descriptions.FirstOrDefault(x => x.IsActive == true && x.Sno == id);
            }
            if (result == null)
            {
                return(null);
            }
            return(_mapper.Map <Index_descriptionViewModel>(result));
        }