Exemplo n.º 1
0
 public ValueDto GetById(int id)
 {
     if (id < 0)
     {
         throw new ArgumentOutOfRangeException();
     }
     return(_valueRepository.GetById <ValueDto>(id));
 }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 public ValueModel Get(int id)
 {
     return(_valueRepository.GetById(id));
 }
Exemplo n.º 6
0
 public async Task <Value> GetValueByIdAsync(Guid id)
 {
     return(await _valueRepository.GetById(id));
 }