public async Task <ISingleResponse <SystemParameter> > GetSystemParameterAsync(int id)
        {
            Logger?.LogInformation("{0} has been invoked", nameof(GetSystemParameterAsync));

            var response = new SingleResponse <SystemParameter>();

            try
            {
                return(new SingleResponse <SystemParameter>(await UnitOfWork.Repository <SystemParameter>().GetByIdAsync(id)));
            }
            catch (Exception ex)
            {
                return(new SingleResponse <SystemParameter>(Logger, nameof(GetSystemParameterAsync), ex));
            }
        }
Пример #2
0
        public async Task <ISingleResponse <User> > UpdateUserRefreshTokenAsync(User loginUser)
        {
            var response = new SingleResponse <User>();

            try
            {
                await UserRepository.UpdateUserAsync(loginUser);
            }
            catch (Exception ex)
            {
                response.SetError(ex);
            }

            return(response);
        }
Пример #3
0
        public async Task <SingleResponse <Meal> > GetByName(Meal item)
        {
            SingleResponse <Meal> response = new SingleResponse <Meal>();

            string name = item.Name;

            using (DietDB db = new DietDB())
            {
                Meal meal = await db.Meals.FirstOrDefaultAsync(w => w.Name == name);

                response.Data = meal;
            }

            return(response);
        }
 public IActionResult GetCurrentAccountOverdrafts(ProductQualityFilterRequest request)
 {
     if (ModelState.IsValid)
     {
         SingleResponse <List <CreditLine> > response = new SingleResponse <List <CreditLine> >();
         response.Result     = _xbService.GetCreditLines(request.Filter);
         response.Result     = response.Result.FindAll(m => m.Type == 25 || m.Type == 18 || m.Type == 46 || m.Type == 36 || m.Type == 60);
         response.ResultCode = ResultCodes.normal;
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
Пример #5
0
        // POST
        public async Task <SingleResponse <Users> > CreateUserAsync(Users user)
        {
            var response = new SingleResponse <Users>();

            // Add entity to repository
            DbContext.Add(user, UserInfo);

            await DbContext.SaveChangesAsync();

            response.Message = string.Format("Sucsses Post for user = {0} ", user.EmployeeId);
            // Set the entity to response model
            response.Model = user;

            return(response);
        }
Пример #6
0
        // POST
        public async Task <SingleResponse <EmployeeResponse> > CreateEmployeeAsync(Employee employee)
        {
            var response = new SingleResponse <EmployeeResponse>();

            // Add entity to repository
            DbContext.Add(employee, UserInfo);

            await DbContext.SaveChangesAsync();

            response.Message = string.Format("Sucsses Post for Employee = {0} ", employee.EmployeeId);
            // Set the entity to response model
            response.Model = employee.ToEntity(null, null, null, null, null, null);

            return(response);
        }
Пример #7
0
 public IActionResult GetDepositAndCurrentAccountCurrencies(DepositAndCurrentAccCurrenciesRequest request)
 {
     if (ModelState.IsValid)
     {
         SingleResponse <List <string> > response = new SingleResponse <List <string> >();
         response.Result = _xbService.GetDepositAndCurrentAccountCurrencies(request.OrderType, request.OrderSubtype, request.OrderAccountType);
         response.Result.Reverse();
         response.ResultCode = ResultCodes.normal;
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
        public async Task <IActionResult> Login(string returnUrl = null)
        {
            // Clear the existing external cookie to ensure a clean login process
            var response = new SingleResponse <ReturnUrlResponseViewModel>();
            await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);

            var returnurl = new ReturnUrlResponseViewModel
            {
                ReturnUrl = returnUrl
            };

            response.Data   = returnurl;
            response.Status = true;
            return(response.ToHttpResponse());
        }
Пример #9
0
        // Pega o ID de uma venda
        public SingleResponse <VendaProduto> GetVendaID(int id)
        {
            SingleResponse <VendaProduto> response = new SingleResponse <VendaProduto>();

            // responsável por realizar conexão física com o banco
            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = ConnectionString.GetConnectionString();

            SqlCommand command = new SqlCommand();

            command.CommandText = "SELECT IDENT_CURRENT ('VENDAPRODUTOS') AS CURRENT_ID";

            command.Connection = connection;

            try
            {
                connection.Open();

                SqlDataReader reader = command.ExecuteReader();

                if (reader.Read())
                {
                    response.Success = true;
                    VendaProduto vendaProduto = new VendaProduto();
                    vendaProduto.ID = Convert.ToInt32(reader["CURRENT_ID"]);
                    response.Data   = vendaProduto;
                }
                else
                {
                    response.Success = false;
                    response.Message = "Funcionário(a) não encontrado(a)!";
                }
                return(response);
            }
            catch (Exception ex)
            {
                response.Success        = false;
                response.Message        = "Erro no Banco de Dados, contate um ADM!";
                response.StackTrace     = ex.StackTrace;
                response.ExceptionError = ex.Message;
            }
            finally
            {
                connection.Close();
            }
            return(response);
        }
Пример #10
0
        // Pega um produto pelo nome
        public SingleResponse <Produto> GetByNome(Produto produto)
        {
            SingleResponse <Produto> response = new SingleResponse <Produto>();

            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = ConnectionString.GetConnectionString();

            SqlCommand command = new SqlCommand();

            command.CommandText = "SELECT * FROM PRODUTOS WHERE NOME = @NOME";
            command.Parameters.AddWithValue("@NOME", produto.Nome);

            command.Connection = connection;

            try
            {
                connection.Open();

                SqlDataReader reader = command.ExecuteReader();

                if (reader.Read())
                {
                    produto.ID            = (int)reader["ID"];
                    produto.Nome          = (string)reader["NOME"];
                    produto.Descricao     = (string)reader["DESCRICAO"];
                    produto.ValorUnitario = (double)reader["VALORUNITARIO"];
                    produto.QtdEstoque    = (int)reader["QTDESTOQUE"];
                    response.Data         = produto;
                }

                response.Success = true;
                response.Message = "Dados selecionados com sucesso!";
                return(response);
            }
            catch (Exception ex)
            {
                response.Success        = false;
                response.Message        = "Erro no Banco de Dados, contate um ADM!";
                response.StackTrace     = ex.StackTrace;
                response.ExceptionError = ex.Message;
                return(response);
            }
            finally
            {
                connection.Close();
            }
        }
            static PlanResult Run(
                IRestApi restApi,
                string ciName,
                string planPath,
                string objectSpec,
                string comment,
                Dictionary <string, string> properties,
                int maxWaitTimeSeconds)
            {
                LaunchPlanRequest request = new LaunchPlanRequest()
                {
                    ObjectSpec = objectSpec,
                    Comment    = string.Format("MergeBot - {0}", comment),
                    Properties = properties
                };

                SingleResponse planResponse = restApi.CI.LaunchPlan(
                    ciName, planPath, request);

                GetPlanStatusResponse statusResponse =
                    Task.Run(() =>
                             WaitForFinishedPlanStatus(
                                 restApi,
                                 ciName,
                                 planResponse.Value,
                                 planPath,
                                 maxWaitTimeSeconds)
                             ).Result;

                if (statusResponse != null)
                {
                    return(new PlanResult()
                    {
                        Succeeded = statusResponse.Succeeded,
                        Explanation = statusResponse.Explanation
                    });
                }

                return(new PlanResult()
                {
                    Succeeded = false,
                    Explanation = string.Format(
                        "{0} reached the time limit to get the status " +
                        "for plan:'{1}' and executionId:'{2}'" +
                        "\nRequest details: objectSpec:'{3}' and comment:'{4}'",
                        ciName, planPath, planResponse.Value, objectSpec, comment)
                });
            }
Пример #12
0
        public SingleResponse <Produto> GetById(int id)
        {
            SingleResponse <Produto> response = new SingleResponse <Produto>();

            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = ConnectionHelper.GetConnectionString();

            SqlCommand command = new SqlCommand();

            command.CommandText = "SELECT * FROM PRODUTOS WHERE ID = @ID";
            command.Parameters.AddWithValue("@ID", id);
            command.Connection = connection;

            try
            {
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                    Produto produto = new Produto();
                    produto.ID           = (int)reader["ID"];
                    produto.Nome         = (string)reader["NOME"];
                    produto.Preco        = (double)reader["PRECO"];
                    produto.Estoque      = (int)reader["ESTOQUE"];
                    produto.DataValidade = (DateTime)reader["DATAVALIDADE"];
                    response.Message     = "Dados selecionados com sucesso.";
                    response.Success     = true;
                    response.Data        = produto;
                    return(response);
                }
                response.Message = "Produto não encontrado.";
                response.Success = false;
                return(response);
            }
            catch (Exception ex)
            {
                response.Success        = false;
                response.Message        = "Erro no banco de dados contate o adm.";
                response.ExceptionError = ex.Message;
                response.StackTrace     = ex.StackTrace;
                return(response);
            }
            finally
            {
                connection.Close();
            }
        }
        public SingleResponse <IList <ClienteProductoModel> > ConsultarClientesConfigurarParametros(ClienteProductoModel clienteProductoModel)
        {
            SingleResponse <IList <ClienteProductoModel> > response = new SingleResponse <IList <ClienteProductoModel> >();

            try
            {
                IList <ClienteProductoModel> listaClienteProducto = iConfigurarParametrosTicketsDataAccess.ConsultarClientesConfigurarParametros(clienteProductoModel);
                var qry = listaClienteProducto.GroupBy(cm => new
                {
                    cm.IdCliente,
                    cm.NombreCliente
                },
                                                       (key, group) => new
                {
                    Key1 = key.IdCliente,
                    Key2 = key.NombreCliente
                });

                List <ClienteProductoModel> clientesAgrupados = new List <ClienteProductoModel>();
                foreach (var cliente in qry)
                {
                    ClienteProductoModel clienteProductoModel2 = new ClienteProductoModel
                    {
                        IdCliente     = cliente.Key1,
                        NombreCliente = cliente.Key2
                    };
                    clientesAgrupados.Add(clienteProductoModel2);
                }
                response.Done(clientesAgrupados, string.Empty);
            }
            catch (DalException e)
            {
                response.Error(e);
            }
            catch (DomainValidationsException e)
            {
                response.SetValidations(e.Validations);
            }
            catch (DomainException e)
            {
                response.Error(e);
            }
            catch (Exception e)
            {
                response.Error(new DomainException(CodesConfigParamTickets.ERR_08_03, e));
            }
            return(response);
        }
Пример #14
0
        public async Task <ISingleResponse <Article> > PatchArticle(Article article)
        {
            ISingleResponse <Article> response = new SingleResponse <Article>()
            {
                IsSuccess = false
            };

            try
            {
                Article itemToUpdate = _dbContext.Articles.FirstOrDefault(a => a.Id == article.Id);

                if (itemToUpdate != null)
                {
                    if (!string.IsNullOrWhiteSpace(article.Title))
                    {
                        itemToUpdate.Title = article.Title;
                    }

                    if (!string.IsNullOrWhiteSpace(article.FirstParagraph))
                    {
                        itemToUpdate.FirstParagraph = article.FirstParagraph;
                    }

                    if (!string.IsNullOrWhiteSpace(article.Body))
                    {
                        itemToUpdate.Body = article.Body;
                    }

                    if (!string.IsNullOrWhiteSpace(article.ImageUrl))
                    {
                        itemToUpdate.ImageUrl = article.ImageUrl;
                    }

                    response = await _articleRepository.UpdateArticle(itemToUpdate);
                }
                else
                {
                    response.Message = $"Article with id {article.Id} not found";
                }
            }
            catch (Exception e)
            {
                response.IsSuccess = false;
                response.Message   = e.Message;
            }

            return(response);
        }
Пример #15
0
        public async Task <SingleResponse <Diet> > GetById(int id)
        {
            SingleResponse <Diet> response = new SingleResponse <Diet>();

            using (DietDB db = new DietDB())
            {
                Diet diet = await db.Diets.Include(c => c.Meals).FirstOrDefaultAsync(w => w.ID == id);

                if (diet != null)
                {
                    response.Data = diet;
                    return(ResponseFactory.SingleResponseSuccessModel <Diet>(diet));
                }
                return(ResponseFactory.SingleResponseNotFoundException <Diet>());
            }
        }
Пример #16
0
 public IActionResult GetHBServletRequestOrder(IdRequest request)
 {
     if (ModelState.IsValid)
     {
         SingleResponse <HBServletRequestOrder> response = new SingleResponse <HBServletRequestOrder>
         {
             Result     = _xBService.GetHBServletRequestOrder(request.Id),
             ResultCode = ResultCodes.normal
         };
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
Пример #17
0
 public IActionResult SaveHBServletTokenUnBlockRequestOrder(HBServletRequestOrderRequest request)
 {
     if (ModelState.IsValid)
     {
         SingleResponse <long> response = new SingleResponse <long>();
         XBS.ActionResult      result   = _xBService.SaveHBServletTokenUnBlockRequestOrder(request.Order);
         response.Result      = result.Id;
         response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(result.ResultCode);
         response.Description = utils.GetActionResultErrors(result.Errors);
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
 public IActionResult GetEmployeeSalaryDetails(GenericIdRequest ID)
 {
     if (ModelState.IsValid)
     {
         var response = new SingleResponse <EmployeeSalaryDetails>()
         {
             ResultCode = ResultCodes.normal
         };
         response.Result = _xbService.GetEmployeeSalaryDetails(ID.Id);
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
 public IActionResult GetEmployeePersonalDetails()
 {
     if (ModelState.IsValid)
     {
         var response = new SingleResponse <EmployeePersonalDetails>()
         {
             ResultCode = ResultCodes.normal
         };
         response.Result = _xbService.GetEmployeePersonalDetails();
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
Пример #20
0
 public IActionResult GetDepositLoanOrDepositCreditLineContract(LoanOrCreditLineContractRequest request)
 {
     if (ModelState.IsValid)
     {
         var response = new SingleResponse <byte[]>()
         {
             ResultCode = ResultCodes.normal
         };
         response.Result = _xbService.GetDepositLoanOrDepositCreditLineContract(request.LoanNumber, request.Type);
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
Пример #21
0
 public IActionResult GetPlasticCardSMSServiceTariff(ProductIdRequest productIdRequest)
 {
     if (ModelState.IsValid)
     {
         SingleResponse <float> response = new SingleResponse <float>()
         {
             ResultCode = ResultCodes.normal
         };
         response.Result = _xbService.GetPlasticCardSMSServiceTariff(productIdRequest.ProductId)[1];
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
Пример #22
0
 public IActionResult GetVirtualCardDetails(CardNumberRequest virtualCardDetails)
 {
     if (ModelState.IsValid)
     {
         var response = new SingleResponse <VirtualCardDetails>()
         {
             ResultCode = ResultCodes.normal
         };
         response.Result = _xbService.GetVirtualCardDetails(virtualCardDetails.CardNumber);
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
Пример #23
0
 public IActionResult GetFactoring(ProductIdRequest request)
 {
     if (ModelState.IsValid)
     {
         var response = new SingleResponse <Factoring>()
         {
             ResultCode = ResultCodes.normal
         };
         response.Result = _xbService.GetFactoring(request.ProductId);
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
Пример #24
0
 public IActionResult GetLinkedAndAttachedCards(LinkedAndAttachedCardsRequest request)
 {
     if (ModelState.IsValid)
     {
         SingleResponse <List <Card> > response = new SingleResponse <List <Card> >()
         {
             ResultCode = ResultCodes.normal
         };
         response.Result = _xbService.GetLinkedAndAttachedCards(request.ProductId, request.ProductFilter);
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
Пример #25
0
 public IActionResult GetCardByCardNumber(CardNumberRequest request)
 {
     if (ModelState.IsValid)
     {
         SingleResponse <Card> response = new SingleResponse <Card>()
         {
             ResultCode = ResultCodes.normal
         };
         response.Result = _xbService.GetCardByCardNumber(request.CardNumber);
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
Пример #26
0
        // POST
        public async Task <SingleResponse <SiteEmployee> > CreateSiteEmployeeAsync(SiteEmployee siteEmployee)
        {
            var response = new SingleResponse <SiteEmployee>();

            // Add entity to repository
            DbContext.Add(siteEmployee, UserInfo);
            // Save entity in database
            await DbContext.SaveChangesAsync();


            response.SetMessageSucssesPost(nameof(SiteEmployee), siteEmployee.SiteEmployeeId);
            // Set the entity to response model
            response.Model = siteEmployee;

            return(response);
        }
Пример #27
0
 public IActionResult SaveProductNote(ProductNoteRequest request)
 {
     if (ModelState.IsValid)
     {
         SingleResponse <long> response = new SingleResponse <long>();
         response.ResultCode = ResultCodes.normal;
         XBS.ActionResult result = _xbService.SaveProductNote(request.ProductNote);
         response.Result      = result.Id;
         response.Description = Utils.GetActionResultErrors(result.Errors);
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
 public IActionResult GetEmployeeSalaryList(StartDateEndDateRequest startDateEndDateRequest)
 {
     if (ModelState.IsValid)
     {
         var response = new SingleResponse <List <EmployeeSalary> >()
         {
             ResultCode = ResultCodes.normal
         };
         response.Result = _xbService.GetEmployeeSalaryList(startDateEndDateRequest.StartDate, startDateEndDateRequest.EndDate);
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
Пример #29
0
 public IActionResult GetCardLimits(ProductIdRequest request)
 {
     if (ModelState.IsValid)
     {
         var response = new SingleResponse <List <KeyValuePair <string, string> > >()
         {
             ResultCode = ResultCodes.normal
         };
         response.Result = _xbService.GetCardLimits((long)request.ProductId);
         return(ResponseExtensions.ToHttpResponse(response));
     }
     else
     {
         return(ValidationError.GetValidationErrorResponse(ModelState));
     }
 }
Пример #30
0
        public async Task <SingleResponse <Food> > GetById(int id)
        {
            SingleResponse <Food> response = new SingleResponse <Food>();

            using (DietDB db = new DietDB())
            {
                Food food = await db.Foods.FirstOrDefaultAsync(w => w.ID == id);

                if (food != null)
                {
                    response.Data = food;
                    return(ResponseFactory.SingleResponseSuccessModel <Food>(food));
                }
                return(ResponseFactory.SingleResponseNotFoundException <Food>());
            }
        }