Beispiel #1
0
        public async Task <bool> CreateAsync(CategorysRequestDto dto)
        {
            var model = _mapper.Map <Categorys>(dto);

            model.CreationTime = DateTime.Now;
            var task = await _context.Categorys.AddAsync(model);

            await _context.SaveChangesAsync();

            return(model.Id != 0);
        }
Beispiel #2
0
        public async Task <bool> EditAsync(CategorysRequestDto dto)
        {
            var category = _context.Categorys.FirstOrDefault(p => p.Id == dto.Id);

            if (category == null)
            {
                return(false);
            }

            _mapper.Map(dto, category);
            category.LastModificationTime = DateTime.Now;
            await _context.SaveChangesAsync();

            return(true);
        }