public void Drop(ExDragEventArgs arg)
        {
            var app          = (ScheduleEntryBaseViewModel)arg.DragEventArgs.Data.GetData("myFormat");
            var championship = (ChampionshipItem)arg.DragEventArgs.Data.GetData("ChampionshipItem");
            var activity     = (ActivityDTO)arg.DragEventArgs.Data.GetData("ActivityDTO");
            var group        = (CustomerGroupDTO)arg.DragEventArgs.Data.GetData("CustomerGroupDTO");
            var myPlace      = (MyPlaceLightDTO)arg.DragEventArgs.Data.GetData("MyPlaceDTO");
            CalendarTimeslotItem emptySlot = arg.DirectTarget as CalendarTimeslotItem;

            if (emptySlot == null)
            {
                return;
            }
            ScheduleEntryBaseDTO baseDTO;

            if (activity != null)
            {
                var dto = new ScheduleEntryDTO();
                dto.ActivityId = activity.GlobalId;
                dto.MaxPersons = activity.MaxPersons;
                dto.Price      = activity.Price;
                dto.StartTime  = emptySlot.StartTime.ToUniversalTime();
                dto.EndTime    = dto.StartTime + activity.Duration;
                app            = createAppointment(dto);
                baseDTO        = dto;
            }
            else if (championship != null)
            {
                var dto = new ScheduleChampionshipDTO();
                dto.StartTime        = emptySlot.StartTime.ToUniversalTime();
                dto.ChampionshipType = championship.Value;

                dto.Name    = InstructorHelper.Translate(dto.ChampionshipType);
                dto.EndTime = dto.StartTime + TimeSpan.FromHours(4);
                app         = createAppointment(dto);
            }
            else if (group != null)
            {
                var dto = new ScheduleEntryDTO();
                dto.MaxPersons = group.MaxPersons;
                dto.StartTime  = emptySlot.StartTime.ToUniversalTime();
                dto.EndTime    = dto.StartTime + TimeSpan.FromHours(1);//default entry length is one hour
                if (group.DefaultActivityId.HasValue)
                {
                    activity       = ActivitiesReposidory.Instance.GetItem(group.DefaultActivityId.Value);
                    dto.MaxPersons = activity.MaxPersons;
                    dto.ActivityId = activity.GlobalId;
                    dto.Price      = activity.Price;
                    dto.EndTime    = dto.StartTime + activity.Duration;
                }

                dto.CustomerGroupId = group.GlobalId;
                app     = createAppointment(dto);
                baseDTO = dto;
            }
            else if (myPlace != null)
            {
                var dto = new ScheduleEntryDTO();
                dto.MyPlaceId = myPlace.GlobalId;
                dto.StartTime = emptySlot.StartTime.ToUniversalTime();
                dto.EndTime   = dto.StartTime + TimeSpan.FromHours(1);//default entry length is one hour
                app           = createAppointment(dto);
                baseDTO       = dto;
            }

            if ((arg.DragEventArgs.KeyStates & DragDropKeyStates.ControlKey) == DragDropKeyStates.ControlKey)
            {
                app             = app.Clone(true);
                baseDTO         = app.Item;
                baseDTO.Version = 0;
            }


            TimeSpan diff = app.RealEndTime - app.StartTime;

            app.Item.StartTime = emptySlot.StartTime.ToUniversalTime();
            app.Item.EndTime   = (app.StartTime + diff).ToUniversalTime();
            if (Entries.IndexOf(app) == -1)
            {
                Entries.Add(app);
            }
            IsModified = true;
        }
Exemple #2
0
 public ChampionshipItem(ChampionshipType type) : base(InstructorHelper.Translate(type), type)
 {
     Brush = Brushes.Thistle;
 }