Пример #1
0
        public async Task <ResponseBase> DeleteAsync(string id)
        {
            var user = await _productRepository.GetByIdAsync(id);

            if (user == null)
            {
                _responseBase.AddMessage(string.Format(Message.X0_X1_NAO_ENCONTRADO, Message.O, Message.Produto));
                return(_responseBase);
            }
            user.SetDeleted(true);
            _productRepository.Put(user);

            return(_responseBase);
        }
        public async Task <ResponseBase> DeleteAsync(string id)
        {
            var order = await _orderRepository.GetByIdAsync(id);

            if (order == null)
            {
                _responseBase.AddMessage(string.Format(Message.X0_X1_NAO_ENCONTRADO, Message.O, Message.Pedido));
                return(_responseBase);
            }

            order.SetDeleted(true);
            _orderRepository.Put(order);

            return(_responseBase);
        }
        public ResponseBase <RemoteFileDetail> GetFileInfo(ResourceDetail rl)
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)GetRequest(rl);
                //request.Timeout = 100000;

                HttpWebResponse  response = (HttpWebResponse)request.GetResponse();
                RemoteFileDetail result   = new RemoteFileDetail
                {
                    MimeType     = response.ContentType,
                    LastModified = response.LastModified,
                    FileSize     = response.ContentLength,
                    AcceptRanges = Compare(response.Headers["Accept-Ranges"], "bytes", StringComparison.OrdinalIgnoreCase) == 0
                };
                return(new ResponseBase <RemoteFileDetail>()
                {
                    Denied = false, ReturnedValue = result
                });
            }
            catch (Exception ex)
            {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                Serilog.Log.Error(ex, "---Could not get remote file information trial number");
                var responseFailed = new ResponseBase <RemoteFileDetail>()
                {
                    Denied = true
                };
                responseFailed.AddMessage(ex.Message);
                return(responseFailed);
            }
        }
        public async Task <ResponseBase> UpdateAsync(UserRequest userRequest)
        {
            var user = await _userRepository.GetByIdAsync(userRequest.Id);

            if (user == null)
            {
                _responseBase.AddMessage(string.Format(Message.X0_X1_NAO_ENCONTRADO, null, Message.Usuario));
                return(_responseBase);
            }

            user.SetEmail(userRequest.Email);
            user.SetFirstName(userRequest.FirstName);
            user.SetNickName(userRequest.NickName);
            user.SetFullName(userRequest.FullName);

            if (user.IsFailure)
            {
                _responseBase.AddMessages(user.Errors);
                return(_responseBase);
            }

            _userRepository.Put(user);
            return(_responseBase);
        }