Ejemplo n.º 1
0
        protected virtual async Task Create(VideoCategoryDto input)
        {
            VideoCategory videoDto = MappingProfile.MappingConfigurationSetups().Map <VideoCategory>(input);

            _context.VideoCategory.Add(videoDto);
            await _context.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        protected virtual async Task Update(VideoCategoryDto input)
        {
            var category = await _context.VideoCategory.Where(x => x.Id == input.Id).FirstOrDefaultAsync();

            if (category != null)
            {
                VideoCategory categoryDto = MappingProfile.MappingConfigurationSetups().Map <VideoCategory>(input);
                _context.VideoCategory.Update(categoryDto);
                await _context.SaveChangesAsync();
            }
        }
Ejemplo n.º 3
0
 public async Task CreateOrEditVideoCategory(VideoCategoryDto input)
 {
     if (input.Id == null || input.Id == 0)
     {
         await Create(input);
     }
     else
     {
         await Update(input);
     }
 }
Ejemplo n.º 4
0
        public async Task <VideoCategoryDto> GetVideoCategoryForEdit(VideoCategoryDto input)
        {
            var categories = await _context.VideoCategory.Where(x => x.Id == input.Id).FirstOrDefaultAsync();

            if (categories != null)
            {
                VideoCategory categoryDto = MappingProfile.MappingConfigurationSetups().Map <VideoCategory>(input);
                _context.VideoCategory.Update(categoryDto);
                await _context.SaveChangesAsync();

                return(MappingProfile.MappingConfigurationSetups().Map <VideoCategoryDto>(categoryDto));
            }
            return(new VideoCategoryDto());
        }
Ejemplo n.º 5
0
        public List <VideoCategoryDto> GetAllVideoCategory(VideoCategoryDto input)
        {
            var allCategories = _context.VideoCategory.ToList().Skip((input.PagedResultDto.Page - 1) * input.PagedResultDto.SkipCount).Take(input.PagedResultDto.MaxResultCount);


            // Map Records
            List <VideoCategoryDto> categoryDto = MappingProfile.MappingConfigurationSetups().Map <List <VideoCategoryDto> >(allCategories);

            //Apply Sort
            categoryDto = Sort(input.PagedResultDto.Sort, input.PagedResultDto.SortOrder, categoryDto);

            // Apply search
            if (!string.IsNullOrEmpty(input.PagedResultDto.Search))
            {
                categoryDto = categoryDto.Where(p => p.Status != null && p.Status.ToLower().ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower()) ||
                                                p.Name != null && p.Name.ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower()) ||
                                                p.DateCreated != null && p.DateCreated.ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower())
                                                ).ToList();
            }
            return(categoryDto);
        }
Ejemplo n.º 6
0
 public List <VideoCategoryDto> GetAllVideoCategory(VideoCategoryDto input)
 {
     return(_unitOfWork.VideoCategory.GetAllVideoCategory(input));
 }
Ejemplo n.º 7
0
 public async Task GetVideoCategoryForEdit(VideoCategoryDto input)
 {
     await _unitOfWork.VideoCategory.GetVideoCategoryForEdit(input);
 }
Ejemplo n.º 8
0
 public async Task CreateOrEditVideoCategory(VideoCategoryDto input)
 {
     await _unitOfWork.VideoCategory.CreateOrEditVideoCategory(input);
 }