public TimeSheetViewModel Add(TimeSheetViewModel viewModel) { var model = _repository.Add(viewModel.ToTimeSheetEntity()); _repository.Save(); return(new TimeSheetViewModel(model)); }
public Task Handle(CreateNewTimeSheetCommand message, CancellationToken cancellationToken) { if (!message.IsValid()) { NotifyValidationErrors(message); return(Task.CompletedTask); } var timeSheet = new TimeSheet(Guid.NewGuid(), message.HoursWorked, message.DateWorked, message.UserId); _timeSheetRepository.Add(timeSheet); if (Commit()) { _bus.RaiseEvent(new TimeSheetCreatedEvent(timeSheet.Id, timeSheet.HourWorked, timeSheet.DateWorked, timeSheet.UserId)); } return(Task.CompletedTask); }