public RestaurantWaiterDTO GetRestaurantWaiter(long waiterId)
        {
            var waiter = _restaurantWaiterService.Find(waiterId);

            if (waiter == null)
            {
                throw new NotFoundException(ErrorCodes.UserNotFound);
            }
            return(Mapper.Map <RestaurantWaiterDTO>(waiter));
        }
        public List <RoomNameDto> GetAllRoomNames(long userId, string role)
        {
            List <RoomNameDto> rooms = null;

            if (role == Enums.RoleType.Admin.ToString())
            {
                rooms = Mapper.Map <List <RoomNameDto> >(_roomService.Query(x => !x.IsDeleted && x.AdminId == userId).Select().ToList());
            }
            else if (role == Enums.RoleType.Supervisor.ToString())
            {
                var adminId = _supervisorService.Find(userId).AdminId;
                rooms = Mapper.Map <List <RoomNameDto> >(_roomService.Query(x => !x.IsDeleted && x.AdminId == adminId).Select().ToList());
            }
            else if (role == Enums.RoleType.Receptionist.ToString())
            {
                var adminId = _receptionistService.Find(userId).AdminId;
                rooms = Mapper.Map <List <RoomNameDto> >(_roomService.Query(x => !x.IsDeleted && x.AdminId == adminId).Select().ToList());
            }
            else if (role == Enums.RoleType.Waiter.ToString())
            {
                var waiter = _restaurantWaiterService.Find(userId);
                rooms = Mapper.Map <List <RoomNameDto> >(_roomService.Query(x => !x.IsDeleted && x.AdminId == waiter.Branch.Restaurant.AdminId).Select().ToList());
            }
            return(rooms);
        }
Exemple #3
0
        public PagedResultsDto GetActivatedMenusByWaiterId(string language, long userId, int page, int pageSize)
        {
            var waiter = _restaurantWaiterService.Find(userId);

            if (waiter == null)
            {
                throw new NotFoundException(ErrorCodes.RestaurantAdminNotFound);
            }
            var result = _menuTranslationService.GetActivatedMenusByRestaurantId(language, waiter.RestaurantId, page, pageSize);

            //result.IsParentTranslated = language == Strings.DefaultLanguage || _restaurantTranslationService.CheckRestaurantByLanguage(restaurantAdminId, language);
            return(result);
        }
        public PagedResultsDto GetAllRequests(long userId, int page, int pageSize, string role, long roomId, long featureId, string from, string to)
        {
            var user = _userService.Find(userId);

            if (user == null)
            {
                throw new ValidationException(ErrorCodes.UserNotFound);
            }
            if (user.IsDeleted)
            {
                throw new ValidationException(ErrorCodes.UserDeleted);
            }
            if (!user.IsActive)
            {
                throw new ValidationException(ErrorCodes.UserDeactivated);
            }
            int requestsCount          = 0;
            List <RequestDto> requests = null;

            if (role == Enums.RoleType.Admin.ToString())
            {
                DateTime fromDateTime = !String.IsNullOrEmpty(from) ? DateTime.Parse(from) : DateTime.MinValue;
                DateTime toDateTime   = !String.IsNullOrEmpty(to) ? DateTime.Parse(to) : DateTime.MaxValue;
                requestsCount = _requestService.Query(x => x.Creater.AdminId == userId &&
                                                      (roomId <= 0 || x.CreationBy == roomId) &&
                                                      (featureId <= 0 || x.FeatureId == featureId) &&
                                                      x.CreateTime >= fromDateTime && x.CreateTime <= toDateTime).Select().Count();
                requests = Mapper.Map <List <RequestDto> >(_requestService.GetAllRequestsByAdmin(userId, page, pageSize, roomId, featureId, fromDateTime, toDateTime));
            }
            else if (role == Enums.RoleType.Supervisor.ToString())
            {
                //var supervisor = _supervisorService.Find(userId);
                //var featureIds = supervisor.SupervisorFeatures.Select(x => x.FeatureId);

                DateTime fromDateTime = !String.IsNullOrEmpty(from) ? DateTime.Parse(from) : DateTime.MinValue;
                DateTime toDateTime   = !String.IsNullOrEmpty(to) ? DateTime.Parse(to) : DateTime.MaxValue;
                requestsCount = _requestService
                                .Query(x => x.Feature.SupervisorFeatures.Select(s => s.SupervisorId).Contains(userId) &&
                                       (roomId <= 0 || x.CreationBy == roomId) && (featureId <= 0 || x.FeatureId == featureId) &&
                                       x.CreateTime >= fromDateTime && x.CreateTime <= toDateTime)
                                .Select().Count();
                requests = Mapper.Map <List <RequestDto> >(_requestService.GetAllRequestsBySupervisor(userId, page, pageSize, roomId, featureId, fromDateTime, toDateTime));
            }
            else if (role == Enums.RoleType.Receptionist.ToString())
            {
                DateTime fromDateTime = !String.IsNullOrEmpty(from) ? DateTime.Parse(from) : DateTime.MinValue;
                DateTime toDateTime   = !String.IsNullOrEmpty(to) ? DateTime.Parse(to) : DateTime.MaxValue;
                requestsCount = _requestService
                                .Query(x => x.Feature.Creater.Receptionists.Select(r => r.UserId).Contains(userId) &&
                                       (roomId <= 0 || x.CreationBy == roomId) && (featureId <= 0 || x.FeatureId == featureId) &&
                                       x.CreateTime >= fromDateTime && x.CreateTime <= toDateTime)
                                .Select().Count();
                requests = Mapper.Map <List <RequestDto> >(_requestService.GetAllRequestsByReceptionist(userId, page, pageSize, roomId, featureId, fromDateTime, toDateTime));
            }
            else if (role == Enums.RoleType.Waiter.ToString())
            {
                DateTime fromDateTime = !String.IsNullOrEmpty(from) ? DateTime.Parse(from) : DateTime.MinValue;
                DateTime toDateTime   = !String.IsNullOrEmpty(to) ? DateTime.Parse(to) : DateTime.MaxValue;
                var      waiter       = _restaurantWaiterService.Find(userId);
                requestsCount = _requestService.Query(x => x.RestaurantId == waiter.RestaurantId).Select().Count();
                requests      = Mapper.Map <List <RequestDto> >(_requestService.GetAllRequestsByWaiter(waiter.RestaurantId, page, pageSize, roomId, fromDateTime, toDateTime));
            }

            PagedResultsDto results = new PagedResultsDto
            {
                TotalCount = requestsCount,
                Data       = requests
            };

            return(results);
        }