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; } }
public static Data.DbEntities.DbCategory AsEntity(this Core.Models.Category category) => new Data.DbEntities.DbCategory { Id = category.Id, Description = category.Description, Name = category.Name };