Exemple #1
0
        public bool LogWorkerOrder(LogWorkersOrderRequest request)
        {
            var conn           = GetConnection(ConnectionNames.CSPSqlDatabase);
            var commandWrapper = GetStoredProcCommand("dbo.Insert_Clients_WorkerOrders", conn);

            AddInParameter(commandWrapper, "@CustomerID", DbType.Int32, request.ClientId);
            AddInParameter(commandWrapper, "@UserId", DbType.Int32, request.UserId);

            AddInParameter(commandWrapper, "@ERROR", DbType.String, 1000);
            AddInParameter(commandWrapper, "@ERROR_CODE", DbType.String, 4);

            try
            {
                conn.Open();
                int results = commandWrapper.ExecuteNonQuery();

                var isProcedureSucced = Convert.ToBoolean(results);
                MakeDboLog(request.ToString(), isProcedureSucced.ToString(), "dbo.Insert_Clients_WorkerOrders");

                var errorObject     = GetParameterValue(commandWrapper, "@ERROR");
                var errorCodeObject = GetParameterValue(commandWrapper, "@ERROR_CODE");

                return(Convert.ToBoolean(results));
            }
            finally
            {
                commandWrapper.Dispose();
                conn.Close();
            }
        }
        public LogWorkersOrderRequest GetWorkersOrderRequest(int clientId, int courierId, int userId, Role role, int teamId)
        {
            var request = new LogWorkersOrderRequest
            {
                ClientId   = clientId,
                UserId     = userId,
                CourierId  = courierId,
                Role       = role,
                TeamId     = teamId,
                ActionType = DataBaseCommunication.Mappers.Requests.ActionType.Insert
            };

            return(request);
        }
        public LogWorkersOrderResponse LogWorkerOrder(LogWorkersOrderRequest request)
        {
            var response = new LogWorkersOrderResponse {
                ResponseStatus = ResponseStatus.Success
            };

            var clientsProvider = new ClientsProvider();

            try
            {
                if (request.ActionType == ActionType.Insert)
                {
                    response.isSuccessful = clientsProvider.LogWorkerOrder(request);
                    if (response.isSuccessful)
                    {
                        var refreshClientsRequest = new AllClientsRequest
                        {
                            ActionType = ActionType.Select,
                            Role       = request.Role,
                            TeamId     = request.TeamId
                        };

                        var clientsResponse = GetAllClients(refreshClientsRequest);
                        response.NewClientsList = clientsResponse.Clients;
                    }
                }
                else
                {
                    response.ResponseStatus      = ResponseStatus.Failure;
                    response.ResponseDescription = "Not update action";
                }
            }
            catch (Exception ex)
            {
                response.ResponseStatus      = ResponseStatus.Failure;
                response.ResponseDescription = ex.Message;
            }
            return(response);
        }