Ejemplo n.º 1
0
        /// <summary>
        /// Get all the (active) customers of the logged in client
        /// </summary>
        /// <returns></returns>
        public IEnumerable <ClientCustomerDTO> GetClientCustomers()
        {
            var clientId = _clientUserService.GetUserClientId(_currentUserId);

            if (!clientId.HasValue)
            {
                return(new List <ClientCustomerDTO>());
            }

            var clientCustomers    = _unitOfWork.ClientCustomers.GetClientCustomersByClientId((int)clientId).Where(x => x.Status == Status.Active);
            var clientCustomerDTOs = AutoMapper.Mapper.Map <IEnumerable <ClientCustomerDTO> >(clientCustomers);

            return(clientCustomerDTOs);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns the list of workOrders that belongs to the current logged in user
        /// </summary>
        /// <returns>List of workOrders or empty list</returns>
        public IEnumerable <WorkOrderDTO> GetWorkOrders()
        {
            var clientId = _clientUserService.GetUserClientId(_currentUserId);

            if (!clientId.HasValue)
            {
                return(new List <WorkOrderDTO>());
            }

            var workOrders    = _unitOfWork.WorkOrders.GetWorkOrdersByClientId((int)clientId);
            var workOrderDTOs = AutoMapper.Mapper.Map <IEnumerable <WorkOrderDTO> >(workOrders);

            return(workOrderDTOs);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns the list of products that belongs to the current logged in user
        /// </summary>
        /// <returns>List of products or empty list</returns>
        public IEnumerable <ProductDTO> GetProducts()
        {
            var clientId = _clientUserService.GetUserClientId(_currentUserId);

            if (!clientId.HasValue)
            {
                return(new List <ProductDTO>());
            }

            var products    = _unitOfWork.Products.GetProductsByClientId((int)clientId);
            var productDTOs = AutoMapper.Mapper.Map <IEnumerable <ProductDTO> >(products);

            return(productDTOs);
        }
        /// <summary>
        /// Get all the (active) locations that belong to my customers
        /// </summary>
        /// <returns></returns>
        public IEnumerable <CustomerLocationDTO> GetAllMyCustomerLocations()
        {
            var clientId        = _clientUserService.GetUserClientId(_currentUserId);
            var clientCustomers = _clientCustomerService.GetClientCustomers();

            var customerLocations = (from cl in _unitOfWork.CustomerLocations.GetAll()
                                     join cc in clientCustomers on cl.CustomerId equals cc.CustomerId
                                     where cc.ClientId == clientId && cl.Status == Status.Active
                                     select cl).ToList();

            if (customerLocations == null)
            {
                return(new List <CustomerLocationDTO>());
            }

            var customerLocationDTOs = AutoMapper.Mapper.Map <IEnumerable <CustomerLocationDTO> >(customerLocations);

            return(customerLocationDTOs);
        }