Ejemplo n.º 1
0
        public async Task <IActionResult> GetDepartments([FromQuery] DepartmentQueryResource filterResource)
        {
            if (!_auth.IsValidUser(User))
            {
                return(NoContent());
            }

            var filter = _mapper.Map <DepartmentQueryResource, MdaDepartmentQuery>(filterResource);

            var departments = await _repo.GetDepartments(filter);

            Response.AddPagination(departments.CurrentPage, departments.PageSize, departments.TotalCount, departments.TotalPages);

            var departmentsList = _mapper.Map <IEnumerable <DepartmentForList> >(departments);

            return(Ok(departmentsList));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetSimCards([FromQuery] SimCardQueryResource filterResource)
        {
            if (!_auth.IsValidUser(User))
            {
                return(NoContent());
            }

            var filter = _mapper.Map <SimCardQueryResource, MdaSimCardQuery>(filterResource);

            var simCards = await _repo.GetSimCards(filter);

            Response.AddPagination(simCards.CurrentPage, simCards.PageSize,
                                   simCards.TotalCount, simCards.TotalPages);

            var simCardsList = _mapper.Map <IEnumerable <SimCardForList> >(simCards);

            return(Ok(simCardsList));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> GetDevices([FromQuery] DeviceQueryResource filterResource)
        {
            // if(!Helpers.Extensions.IdentifyUser(this.GetUserName()))
            if (!_auth.IsValidUser(User))
            {
                return(NoContent());
            }
            // if(!Helpers.Extensions.IdentifyUser(User))
            //     return NoContent();
            var filter = _mapper.Map <DeviceQueryResource, MdaDeviceQuery>(filterResource);

            var devices = await _repo.GetDevices(filter);

            Response.AddPagination(devices.CurrentPage, devices.PageSize, devices.TotalCount, devices.TotalPages);

            var devicesList = _mapper.Map <IEnumerable <DeviceForList> >(devices);

            return(Ok(devicesList));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> GetAssignees([FromQuery] AssigneeQueryResource filterResource)
        {
            if (!_auth.IsValidUser(User))
            {
                return(NoContent());
            }

            if (filterResource.PageSize == 0)
            {
                filterResource.PageSize = 10;
            }

            var filter = _mapper.Map <AssigneeQueryResource, MdaAssigneeQuery>(filterResource);

            var assignees = await _repo.GetAssignees(filter);

            Response.AddPagination(assignees.CurrentPage, assignees.PageSize, assignees.TotalCount, assignees.TotalPages);

            var assigneesList = _mapper.Map <IEnumerable <AssigneeForList> >(assignees);

            return(Ok(assigneesList));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> GetProductTypes([FromQuery] ProductTypeQueryResource filterResource)
        {
            if (!_auth.IsValidUser(User))
            {
                return(NoContent());
            }

            // if (filterResource.PageSize == 0)
            //     filterResource.PageSize = 10;


            var filter = _mapper.Map <ProductTypeQueryResource, MdaProductTypeQuery>(filterResource);

            var productTypes = await _repo.GetProductTypes(filter);

            Response.AddPagination(productTypes.CurrentPage, productTypes.PageSize,
                                   productTypes.TotalCount, productTypes.TotalPages);

            var productTypesList = _mapper.Map <IEnumerable <ProductTypeForList> >(productTypes);

            return(Ok(productTypesList));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> IdentifyUser()
        {
            if (!_auth.IsValidUser(User))
            {
                return(NoContent());
            }

            var userId = _repo.GetAppUserByLogin(User.Identity.Name);

            var user = await _repo.GetAppUser(userId);

            // var user = _repo.GetMdaAppUserByLogin(User.Identity.Name);
            return(Ok(user));
        }