Exemple #1
0
        public async Task <CategoryDto> InsertAsync(CategoryDto dto, CancellationToken cancellationToken)
        {
            try
            {
                var cat = new Core.Models.Category
                {
                    Title      = dto.Title,
                    Color      = dto.Color,
                    is_deleted = false,
                    created_at = DateTime.UtcNow,
                };

                await _dbContext.Categories.AddAsync(cat, cancellationToken);

                await _dbContext.SaveChangesAsync(cancellationToken);

                return(cat.MapToDto());
            }
            catch (Exception e)
            {
                _logger.LogError(e, "InsertAsync");
                throw;
            }
        }
Exemple #2
0
 public static Data.DbEntities.DbCategory AsEntity(this Core.Models.Category category) => new Data.DbEntities.DbCategory
 {
     Id          = category.Id,
     Description = category.Description,
     Name        = category.Name
 };