Пример #1
0
        public IActionResult UpdateRequest([FromBody] DeactivateRequest request)
        {
            if (request == null)
            {
                return(StatusCode(400));
            }

            string authToken = Request.Headers["x-access-token"];

            SessionService.SESSION_STATE state = sessionService.CheckSession(authToken, Convert.ToInt32(request.cid));

            // TODO: Validate status vs session
            if (state == SessionService.SESSION_STATE.INVALID)
            {
                return(StatusCode(401));
            }

            bool response = deactivationService.UpdateRequest(
                request.requestId.ToString(),
                Convert.ToInt32(request.status),
                Convert.ToInt32(request.reason),
                request.cm_notes,
                request.cust_notes,
                Convert.ToDecimal(request.fee)
                );

            return(new ObjectResult(response));
        }
        public IActionResult ValidateSession(int companyId)
        {
            string authToken = Request.Headers["x-access-token"];

            SessionService.SESSION_STATE sessionState = sessionService.CheckSession(authToken, companyId);

            if (sessionState == SessionService.SESSION_STATE.INVALID)
            {
                return(StatusCode(401));
            }

            return(new ObjectResult(sessionState));
        }
        public IActionResult GetCustomerContractData(int companyId)
        {
            string authToken = Request.Headers["x-access-token"];

            SessionService.SESSION_STATE sessionState = sessionService.CheckSession(authToken, companyId);

            if (sessionState != SessionService.SESSION_STATE.MANAGER)
            {
                return(StatusCode(401));
            }

            List <ContractData> contractList = customerService.GetContractData(companyId);

            return(new ObjectResult(contractList));
        }
        public IActionResult GetCustomer(int companyId)
        {
            string authToken = Request.Headers["x-access-token"];

            SessionService.SESSION_STATE sessionState = sessionService.CheckSession(authToken, companyId);

            if (sessionState == SessionService.SESSION_STATE.INVALID)
            {
                return(StatusCode(401));
            }

            Company customer = customerService.GetCustomer(companyId);

            return(new ObjectResult(customer));
        }
        public IActionResult GetDevice(int companyId, string trucknum)
        {
            string authToken = Request.Headers["x-access-token"];

            SessionService.SESSION_STATE sessionState = sessionService.CheckSession(authToken, companyId);

            if (sessionState == SessionService.SESSION_STATE.INVALID)
            {
                return(StatusCode(401));
            }

            List <Device> report = deviceService.GetDeviceFromTrucknum(companyId, trucknum);

            return(new ObjectResult(report));
        }
Пример #6
0
        public IActionResult GetStatusSummary(int companyId)
        {
            string authToken = Request.Headers["x-access-token"];

            SessionService.SESSION_STATE sessionState = sessionService.CheckSession(authToken, companyId);

            if (sessionState == SessionService.SESSION_STATE.INVALID)
            {
                return(StatusCode(401));
            }

            List <StatusSummary> summary = deactivationService.GetStatusSummary(companyId);

            return(new ObjectResult(summary));
        }
Пример #7
0
        public IActionResult GetRequest(string requestId, int companyId)
        {
            string authToken = Request.Headers["x-access-token"];

            SessionService.SESSION_STATE sessionState = sessionService.CheckSession(authToken, companyId);

            if (sessionState == SessionService.SESSION_STATE.INVALID)
            {
                return(StatusCode(401));
            }

            DeactivateRequest report = deactivationService.GetDeactivationRequest(requestId);

            return(new ObjectResult(report));
        }
Пример #8
0
        public StatusCodeResult UpdateRequestReason(UpdateReason update)
        {
            string authToken = Request.Headers["x-access-token"];

            SessionService.SESSION_STATE state = sessionService.CheckSession(authToken, Convert.ToInt32(update.cid));

            // TODO: Validate status vs session
            if (state == SessionService.SESSION_STATE.INVALID)
            {
                return(StatusCode(401));
            }

            bool success = this.deactivationService.UpdateRequestReason(update);

            return((success)? StatusCode(200) : StatusCode(400));
        }
Пример #9
0
        public IActionResult DeactivateDevice([FromBody] DeactivateRequest request)
        {
            // Verify the user request
            string authToken = Request.Headers["x-access-token"];

            SessionService.SESSION_STATE state = sessionService.CheckSession(authToken, request.cid);
            request.userId = sessionService.GetUserId(authToken);

            if (state == SessionService.SESSION_STATE.INVALID || request.userId == -1)
            {
                return(StatusCode(401));
            }

            string requestId = deactivationService.Deactivate(request);

            return(new ObjectResult(requestId));
        }
        public IActionResult GetCustomerList(int page, int pageSize, string query)
        {
            string authToken = Request.Headers["x-access-token"];

            SessionService.SESSION_STATE sessionState = sessionService.CheckSession(authToken);

            if (sessionState == SessionService.SESSION_STATE.INVALID)
            {
                return(StatusCode(401));
            }

            if (query == null)
            {
                query = "";
            }
            List <Company> customers = customerService.GetCustomerList(page, pageSize, query);

            return(new ObjectResult(customers));
        }
Пример #11
0
        public IActionResult UpdateDeviceFees([FromBody] List <Device> deviceList)
        {
            if (deviceList.Count == 0)
            {
                return(StatusCode(400));
            }

            string authToken = Request.Headers["x-access-token"];

            SessionService.SESSION_STATE state = sessionService.CheckSession(authToken, Convert.ToInt32(deviceList[0].cid));

            if (state != SessionService.SESSION_STATE.MANAGER)
            {
                return(StatusCode(401));
            }

            List <bool> response = deactivationService.UpdateDeviceFees(deviceList);

            return(new ObjectResult(response));
        }
Пример #12
0
        public IActionResult GetReport(int companyId, int page, int pageSize,
                                       bool onlyPending, string sortColumn, bool sortAsc, string filterColumn, string filterValue)
        {
            string authToken = Request.Headers["x-access-token"];

            SessionService.SESSION_STATE sessionState = sessionService.CheckSession(authToken, companyId);

            if (sessionState == SessionService.SESSION_STATE.INVALID)
            {
                return(StatusCode(401));
            }

            string[] validSortColumns = { "requestDate", "status", "reason", "completedDate", "username" };
            if (!validSortColumns.Contains(sortColumn))
            {
                sortColumn = "requestDate";
            }
            List <DeactivateRequest> report = deactivationService.GetDeactivationReport(companyId, page, pageSize, onlyPending, sortColumn, sortAsc, filterColumn, filterValue);

            return(new ObjectResult(report));
        }
Пример #13
0
        public IActionResult CancelRequest([FromBody] DeactivateRequest request)
        {
            string authToken = Request.Headers["x-access-token"];

            SessionService.SESSION_STATE state = sessionService.CheckSession(authToken, Convert.ToInt32(request.cid));

            // TODO: Validate status vs session
            if (state == SessionService.SESSION_STATE.INVALID)
            {
                return(StatusCode(401));
            }

            if (request.requestId == null || request.requestId == null)
            {
                return(StatusCode(400));
            }

            bool response = deactivationService.CancelRequest(request.requestId.ToString());

            return(new ObjectResult(response));
        }
Пример #14
0
        public IActionResult RemoveDeviceFromRequest([FromBody] Device device)
        {
            if (device == null || device.cid == null || device.dsn == null || device.requestId == null)
            {
                return(StatusCode(400));
            }

            string authToken = Request.Headers["x-access-token"];

            SessionService.SESSION_STATE state = sessionService.CheckSession(authToken, Convert.ToInt32(device.cid));

            // TODO: Validate status vs session
            if (state == SessionService.SESSION_STATE.INVALID)
            {
                return(StatusCode(401));
            }

            bool response = deactivationService.RemoveDeviceFromRequest(Convert.ToInt32(device.cid), Convert.ToInt32(device.dsn), device.requestId);

            return(new ObjectResult(response));
        }