Exemplo n.º 1
0
        public static GetDriverNameResponse GetDriversByAgentBoss(GetDriverNameRequest request)
        {
            GetDriverNameResponse response = new GetDriverNameResponse();

            try
            {
                if (request.is_boss)
                {
                    if (!AgentBossServices.CheckAgentBoss(request.user_id, request.auth_token, response))
                    {
                        return(response);
                    }
                }
                else
                {
                    if (!SuperUserServices.CheckSuperUser(request.user_id, request.auth_token, response))
                    {
                        return(response);
                    }
                }
                response.driver_names = new List <GetDriverNameDto>();
                using (OrderDao dao = new OrderDao())
                {
                    var driverList = dao.GetDriversByAgentBoss(request.is_boss ? request.user_id : 0);
                    if (driverList != null && driverList.Count > 0)
                    {
                        response.driver_names = driverList.Select(r => new GetDriverNameDto
                        {
                            driver_id   = r.DrvrID,
                            driver_name = r.DriverName
                        }).ToList();
                    }
                    response.code         = 0;
                    response.has_resource = 1;
                    response.message      = MessagesSource.GetMessage("boss.drv.listed");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
        public NegotiatedContentResult <GetDriverNameResponse> PostGetDriverNames([FromBody] GetDriverNameRequest request)
        {
            GetDriverNameResponse resp = ReportsServices.GetDriversByAgentBoss(request);

            return(Content(HttpStatusCode.OK, resp));
        }