public async Task AddForecast(UnicornInput dto) { //var entity = new Unicorn { // Date = dto.Date, // Summary = dto.Summary, // TemperatureC = dto.TemperatureC //}; //await _repository.InsertAsync(entity); //await _uow.CompleteAsync(); }
public async Task AddUnicorn(UnicornInput input) { var unicorn = new Unicorn { Color = input.Color, Name = input.Name, DateOfBirth = input.DateOfBirth }; await _repository.InsertAsync(unicorn); await _uow.CompleteAsync(); }
public async Task DeleteUnicorn(UnicornInput input) { if (input.Id <= 0) { throw new ArgumentOutOfRangeException("unicorn id must be greate than zero."); } var unicorn = await _repository.GetByIdAsync(input.Id); if (unicorn == null) { throw new NullReferenceException($"THere's no unicorn with this id {input.Id}"); } unicorn.Name = input.Name; unicorn.Color = input.Color; unicorn.DateOfBirth = input.DateOfBirth; _repository.Update(unicorn); await _uow.CompleteAsync(); }