コード例 #1
0
        public static TModel FromScheduledExercise <TModel>(ScheduledExercise scheduledExercise) where
        TModel : ScheduledExerciseApiModel, new()
        {
            var model = new TModel();

            model.Id       = scheduledExercise.Id;
            model.TenantId = scheduledExercise.TenantId;
            model.Name     = scheduledExercise.Name;
            return(model);
        }
コード例 #2
0
            public async Task <Response> Handle(Request request)
            {
                var entity = await _context.ScheduledExercises
                             .Include(x => x.Tenant)
                             .SingleOrDefaultAsync(x => x.Id == request.ScheduledExercise.Id && x.Tenant.UniqueId == request.TenantUniqueId);

                if (entity == null)
                {
                    var tenant = await _context.Tenants.SingleAsync(x => x.UniqueId == request.TenantUniqueId);

                    _context.ScheduledExercises.Add(entity = new ScheduledExercise()
                    {
                        TenantId = tenant.Id
                    });
                }

                entity.Name = request.ScheduledExercise.Name;

                await _context.SaveChangesAsync();

                _bus.Publish(new AddedOrUpdatedScheduledExerciseMessage(entity, request.CorrelationId, request.TenantUniqueId));

                return(new Response());
            }
コード例 #3
0
 public static ScheduledExerciseApiModel FromScheduledExercise(ScheduledExercise scheduledExercise)
 => FromScheduledExercise <ScheduledExerciseApiModel>(scheduledExercise);
コード例 #4
0
    public bool scheduleNewExercise(Int32 exerciseID, DateTime start, Int32 userID, bool notification)
    {
        bool rc = false;

        using (var context = new Layer2Container())
        {

            LimitBreaker lb = context.LimitBreakers.Where(x => x.id == userID).FirstOrDefault();
            if (lb != null)
            {
                List<scheduledItem> scheduledItemsForThatDay = new List<scheduledItem>();
                ScheduledExercise newScheduledExercise = new ScheduledExercise();

                //This part is for validating if the exercise can be scheduled for a certain time
                /* scheduledItemsForThatDay = getScheduledItemsByDay(userID, start);
                foreach (var item in scheduledItemsForThatDay)
                {
                    if (item != null && start.AddHours(-1) <= item.startTime && start.AddHours(1) >= item.startTime)
                    {
                        return false;
                    }
                }
                */
                Exercise exercise = context.Exercises.Where(e => e.id == exerciseID).FirstOrDefault();
                newScheduledExercise.Exercise = exercise;
                newScheduledExercise.startTime = start;
                newScheduledExercise.LimitBreakers = lb;
                newScheduledExercise.needEmailNotification = notification;
                context.ScheduledExercises.AddObject(newScheduledExercise);
                context.SaveChanges();
                rc = true;
            }
            return rc;
        }
    }
コード例 #5
0
 public AddedOrUpdatedScheduledExerciseMessage(ScheduledExercise scheduledExercise, Guid correlationId, Guid tenantId)
 {
     Payload        = new { Entity = scheduledExercise, CorrelationId = correlationId };
     TenantUniqueId = tenantId;
 }