public TodoListDto(TodoTransactionEntity todoTransactionEntity) { Id = todoTransactionEntity.Id; Description = todoTransactionEntity.Description; IsCompleted = todoTransactionEntity.IsCompleted; CompletedDate = todoTransactionEntity.CompletedDate; CreatedDate = todoTransactionEntity.CreatedDate; UserId = todoTransactionEntity.UserId; User = new UserDto(todoTransactionEntity.User); }
public async Task <long> AddTodoTransaction(TodoAddRequestDto request, ClaimsPrincipal principal) { var userIdString = principal?.Claims?.FirstOrDefault(c => c.Type == "user_id")?.Value; var todoTransactionEntity = new TodoTransactionEntity(); todoTransactionEntity.Description = request.Description; todoTransactionEntity.UserId = long.Parse(userIdString); todoTransactionEntity.CreatedDate = DateTime.Now; _unitOfWork.Add(todoTransactionEntity); await _unitOfWork.SaveChanges(); return(todoTransactionEntity.Id); }