public ValueDto GetById(int id) { if (id < 0) { throw new ArgumentOutOfRangeException(); } return(_valueRepository.GetById <ValueDto>(id)); }
public async Task <IActionResult> GetCache(Guid id) { var value = await _cache.GetOrSetAsync($"value{id}", async() => await _repository.GetById(id), new DistributedCacheEntryOptions()); if (value is null) { return(NotFound(id)); } return(Ok(value)); }
public async Task <ActionResult> Delete(Guid id) { var value = await _valueRepository.GetById(id); if (value is null) { return(NotFound()); } _valueRepository.Delete(value); await _valueRepository.UnitOfWork.Commit(); return(Ok()); }
public override async Task HandleAsync(CallbackQueryUpdateMessage message) { if (!long.TryParse(Parameter, out long valueId)) { throw new ArgumentException($"Can't perfom DelValue command, id parameter is not a number - {Parameter}"); } var value = _valueRepository.GetById(valueId) ?? throw new ArgumentException($"Can't perfom DelValue command, there is no value with id {valueId}"); value.SetDeleted(); _valueRepository.Update(value); await _botClient.SendTextMessageAsync(message, MessageCode.Done); }
public ValueModel Get(int id) { return(_valueRepository.GetById(id)); }
public async Task <Value> GetValueByIdAsync(Guid id) { return(await _valueRepository.GetById(id)); }