Example #1
0
        public IEnumerable <DTOs.Complaint> Search(int?customerId, DateTime?fromDate, DateTime?untilDate, int?complaintType)
        {
            var filter = PredicateBuilder.New <Complaint>(x => true);

            if (customerId.HasValue)
            {
                filter.And(x => x.OffendingCustomer.Id == customerId);
            }

            if (fromDate.HasValue)
            {
                filter.And(x => x.Date >= fromDate);
            }

            if (untilDate.HasValue)
            {
                filter.And(x => x.Date <= untilDate);
            }

            if (complaintType.HasValue)
            {
                filter.And(x => x.Type == _decodesQueryProcessor.Get <ComplaintTypeDecode>(complaintType ?? 0));
            }

            return(Query().Where(filter).ToList().Select(x => new DTOs.Complaint().Initialize(x)));
        }
        public DTOs.Participant Save(DTOs.Participant participant)
        {
            Participant newParticipant = new Participant()
            {
                Date   = participant.Date,
                Order  = _ordersQueryProcessor.Get(participant.Order.Id ?? 0),
                Status = _decodesQueryProcessor.Get <InvitationStatusDecode>(participant.Status)
            };

            Participant persistedParticipant = Save(newParticipant);

            return(new DTOs.Participant().Initialize(persistedParticipant));
        }
Example #3
0
        public DTOs.Field Save(DTOs.Field field)
        {
            Field newField = new Field
            {
                Name = field.Name,
                Size = _decodesQueryProcessor.Get <FieldSizeDecode>(field.Size),
                Type = _decodesQueryProcessor.Get <FieldTypeDecode>(field.Type),
            };

            Field persistedField = Save(newField);

            return(new DTOs.Field().Initialize(persistedField));
        }
        public DTOs.Order Save(DTOs.Order order)
        {
            // TODO remove EndDate from Order
            Order newOrder = new Order()
            {
                StartDate     = DateUtils.ConvertFromJavaScript(order.StartDate),
                Field         = _fieldsQueryProcessor.Get(order.Field.Id ?? 0),
                PlayersNumber = order.PlayersNumber,
                Status        = _decodesQueryProcessor.Get <OrderStatusDecode>(order.Status),
                Participants  = new List <Participant>()
            };

            Order persistedOrder = Save(newOrder);

            return(new DTOs.Order().Initialize(persistedOrder));
        }
Example #5
0
        public IEnumerable <DTOs.Customer> Search(string firstName, string lastName, int?minAge, int?maxAge, int?region, int?customerId)
        {
            var filter = PredicateBuilder.New <Customer>(x => true);

            if (!string.IsNullOrEmpty(firstName))
            {
                filter.And(x => x.FirstName.Contains(firstName));
            }

            if (!string.IsNullOrEmpty(lastName))
            {
                filter.And(x => x.LastName.Contains(lastName));
            }

            if (minAge.HasValue)
            {
                filter.And(x => x.BirthDate <= DateUtils.GetXYearsEarly(minAge ?? 0));
            }

            if (maxAge.HasValue)
            {
                filter.And(x => x.BirthDate >= DateUtils.GetXYearsEarly(maxAge ?? 0));
            }

            if (region.HasValue)
            {
                RegionDecode regionDecode = _decodesQueryProcessor.Get <RegionDecode>(region);
                filter.And(x => x.Region == regionDecode);
            }

            if (customerId.HasValue)
            {
                filter.And(x => x.Id == customerId);
            }
            var result = Query().Where(filter).ToList().Select(x => new DTOs.Customer().Initialize(x));

            return(result);
        }