public async Task <Guid> Create(SheetCreateRequest request) { var sheet = SheetAggregate.CreateFromRequest(request); await _repo.Add(sheet); return(sheet.Id); }
/// <summary>Создание новой карточки учета времени</summary> /// <param name="request">Запрос на создание карточки</param> /// <returns>Новая карточка учета времени</returns> public static SheetAggregate CreateFromRequest(SheetCreateRequest request) { return(new SheetAggregate() { Id = Guid.NewGuid(), Amount = SpentTime.FromInt(request.Amount), ContractId = request.ContractId, Date = request.Date, EmployeeId = request.EmployeeId, ServiceId = request.ServiceId, IsDeleted = false, }); }
public async Task <IActionResult> Create([FromBody] SheetCreateRequest request) { var isAllowedToCreate = await _contractManager.CheckContractIsActive(request.ContractId); if (isAllowedToCreate != null && !(bool)isAllowedToCreate) { return(BadRequest($"Contract {request.ContractId} is not active or not found.")); } var id = await _sheetManager.Create(request); return(Ok(id)); }
/// <summary>Запрос на создание случайной карточки учета</summary> public static SheetCreateRequest CreateRandomSheetCreateRequest() { var request = new SheetCreateRequest() { Amount = 8, ContractId = Guid.NewGuid(), Date = DateTime.Now, EmployeeId = Guid.NewGuid(), ServiceId = Guid.NewGuid(), }; return(request); }