private void FillCalendar(DateTime startDate, DateTime endDate)
 {
     if (!UserContext.IsInstructor)
     {
         return;
     }
     if (fillCancelSource != null)
     {
         fillCancelSource.Cancel();
         fillCancelSource = null;
     }
     fillCancelSource = parentView.RunAsynchronousOperation(delegate(OperationContext context)
     {
         var param         = new GetScheduleEntriesParam();
         param.StartTime   = startDate.ToUniversalTime();
         param.EndTime     = endDate.ToUniversalTime();
         var pageInfo      = new PartialRetrievingInfo();
         pageInfo.PageSize = -1;
         var items         = ServiceManager.GetScheduleEntries(param, pageInfo);
         if (context != null && context.CancellatioToken.IsCancellationRequested)
         {
             return;
         }
         originalEntries = items.Items.StandardClone().ToArray();
         parentView.SynchronizationContext.Send(delegate
         {
             fillAppointments(items.Items);
             IsModified = false;
         }, null);
     });
 }
Beispiel #2
0
        public PagedResult <ScheduleEntryBaseDTO> GetScheduleEntries(Token token, GetScheduleEntriesParam getScheduleEntriesParam, PartialRetrievingInfo retrievingInfo)
        {
            var securityInfo = SecurityManager.EnsureAuthentication(token);
            var service      = new ScheduleEntryService(Session, securityInfo, Configuration);

            return(service.GetScheduleEntries(getScheduleEntriesParam, retrievingInfo));
        }
        public void All()
        {
            var         profile = (ProfileDTO)profiles[0].Tag;
            SessionData data    = CreateNewSession(profile, ClientInformation);

            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                var param          = new GetScheduleEntriesParam();
                var retrievingInfo = new PartialRetrievingInfo();
                var list           = service.GetScheduleEntries(data.Token, param, retrievingInfo);
                Assert.AreEqual(entries.Count, list.AllItemsCount);
                Assert.AreEqual(entries.Count, list.Items.Count);
            });
        }
        public void Mapper_ActivityId()
        {
            var         profile = (ProfileDTO)profiles[0].Tag;
            SessionData data    = CreateNewSession(profile, ClientInformation);

            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                var param          = new GetScheduleEntriesParam();
                param.ActivityId   = activities[0].GlobalId;
                var retrievingInfo = new PartialRetrievingInfo();
                var list           = service.GetScheduleEntries(data.Token, param, retrievingInfo);
                Assert.AreEqual(activities[0].GlobalId, ((ScheduleEntryDTO)list.Items[0]).ActivityId);
            });
        }
        public void ForUsluga()
        {
            var         profile = (ProfileDTO)profiles[0].Tag;
            SessionData data    = CreateNewSession(profile, ClientInformation);

            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                var param          = new GetScheduleEntriesParam();
                param.ActivityId   = activities[0].GlobalId;
                var retrievingInfo = new PartialRetrievingInfo();
                var list           = service.GetScheduleEntries(data.Token, param, retrievingInfo);
                assert(list, 0, 1, 2);
            });
        }
        public void SinceStartDate()
        {
            var         profile = (ProfileDTO)profiles[0].Tag;
            SessionData data    = CreateNewSession(profile, ClientInformation);

            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                var param          = new GetScheduleEntriesParam();
                param.StartTime    = DateTime.UtcNow.AddDays(-9);
                var retrievingInfo = new PartialRetrievingInfo();
                var list           = service.GetScheduleEntries(data.Token, param, retrievingInfo);
                assert(list, 1, 3, 4);
            });
        }
        public PagedResult <ScheduleEntryBaseDTO> GetScheduleEntries(GetScheduleEntriesParam getScheduleEntriesParam, PartialRetrievingInfo retrievingInfo)
        {
            Log.WriteWarning("GetScheduleEntries:Username={0}", SecurityInfo.SessionData.Profile.UserName);

            if (!SecurityInfo.Licence.IsInstructor)
            {
                throw new LicenceException("This feature is allowed for Instructor account");
            }

            using (var trans = Session.BeginGetTransaction())
            {
                Profile dbProfile = Session.Load <Profile>(SecurityInfo.SessionData.Profile.GlobalId);
                var     query     = Session.QueryOver <ScheduleEntryBase>()
                                    .Fetch(x => x.Reservations).Eager
                                    .Fetch(x => x.Reminder).Eager
                                    .Fetch(x => ((Championship)x).Categories).Eager
                                    .Where(x => x.Profile == dbProfile);


                if (getScheduleEntriesParam.EntryId.HasValue)
                {
                    query = query.Where(x => x.GlobalId == getScheduleEntriesParam.EntryId.Value);
                }
                if (getScheduleEntriesParam.ActivityId.HasValue)
                {
                    //query = query.JoinAlias(x =>((ScheduleEntry) x).Usluga, () => usluga);
                    query = query.Where(x => ((ScheduleEntry)x).Activity.GlobalId == getScheduleEntriesParam.ActivityId.Value);
                }
                if (getScheduleEntriesParam.StartTime.HasValue)
                {
                    query = query.Where(x => x.StartTime >= getScheduleEntriesParam.StartTime.Value);
                }
                if (getScheduleEntriesParam.EndTime.HasValue)
                {
                    query = query.Where(x => x.EndTime <= getScheduleEntriesParam.EndTime.Value);
                }
                query.TransformUsing(new DistinctRootEntityResultTransformer());
                trans.Commit();


                var res = query.ToPagedResults <ScheduleEntryBaseDTO, ScheduleEntryBase>(retrievingInfo);
                return(res);
            }
        }
Beispiel #8
0
        public void PayForReservation()
        {
            var         profile = (ProfileDTO)profiles[0].Tag;
            SessionData data    = CreateNewSession(profile, ClientInformation);
            ScheduleEntryReservationDTO reservation = null;

            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                ReservationsOperationParam param = new ReservationsOperationParam();
                param.CustomerId    = customers[0].GlobalId;
                param.EntryId       = entries[0].GlobalId;
                param.OperationType = ReservationsOperationType.Make;
                reservation         = service.ReservationsOperation(data.Token, param).Reservation;
            });



            var koszyk = new PaymentBasketDTO();

            koszyk.CustomerId = customers[0].GlobalId;
            koszyk.TotalPrice = 20m;
            var zakup = new PaymentDTO();

            zakup.Count   = 1;
            zakup.Product = reservation;
            koszyk.Payments.Add(zakup);

            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                koszyk = service.PaymentBasketOperation(data.Token, koszyk);
            });
            Assert.AreEqual(koszyk.GlobalId, koszyk.Payments[0].PaymentBasketId);
            GetScheduleEntriesParam param1 = new GetScheduleEntriesParam();

            param1.EntryId = entries[0].GlobalId;
            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                var entryData = service.GetScheduleEntries(data.Token, param1, new PartialRetrievingInfo());
                Assert.IsTrue(entryData.Items[0].Reservations.ElementAt(0).IsPaid);
            });
            var dbZakup = Session.Get <Payment>(koszyk.Payments[0].GlobalId);

            Assert.Greater(dbZakup.DateTime, DateTime.MinValue);
        }
 public PagedResult <ScheduleEntryBaseDTO> GetScheduleEntries(Token token, GetScheduleEntriesParam getScheduleEntriesParam, PartialRetrievingInfo retrievingInfo)
 {
     return(exceptionHandling(token, () => InternalService.GetScheduleEntries(token, getScheduleEntriesParam, retrievingInfo)));
 }