Beispiel #1
0
        public bool UpdateClientStatus(UpdateClientStatusRequest request)
        {
            var conn           = GetConnection(ConnectionNames.CSPSqlDatabase);
            var commandWrapper = GetStoredProcCommand("dbo.Update_Client_Status", conn);

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


            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.Update_Client_Services");

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

                return(Convert.ToBoolean(results));
            }
            finally
            {
                commandWrapper.Dispose();
                conn.Close();
            }
        }
        public UpdateClientStatusRequest GetUpdateClientStatusRequest(int clientId, int status, Role role, int teamId)
        {
            var request = new UpdateClientStatusRequest
            {
                ClientId   = clientId,
                Status     = status,
                Role       = role,
                TeamId     = teamId,
                ActionType = DataBaseCommunication.Mappers.Requests.ActionType.Update
            };

            return(request);
        }
        public UpdateClientStatusResponse UpdateClientStatus(UpdateClientStatusRequest request)
        {
            var response = new UpdateClientStatusResponse {
                ResponseStatus = ResponseStatus.Success
            };

            var clientsProvider = new ClientsProvider();

            try
            {
                if (request.ActionType == ActionType.Update)
                {
                    response.isSuccessful = clientsProvider.UpdateClientStatus(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);
        }