コード例 #1
0
 public Appointment(string name, string description, Location location, RehearsalRequest rehReq)
 {
     this.Id = rehReq.Id;
     this.Name = name;
     this.Description = description;
     this.StartTime = rehReq.StartTime;
     this.EndTime = rehReq.EndTime;
     this.Location = location;
     this.Grounded = 0;
     this.Type = EnumAppointmentType.Rehearsal;
 }
コード例 #2
0
        private List<AvailableTime> calcBestTimesForRehRequest(RehearsalRequest rehRequest)
        {
            List<AvailableTime> tempList = new List<AvailableTime>();
            List<AvailableTime> retList = new List<AvailableTime>();

            foreach (Musician m in currentBand.MusiciansWithLeader)
            {
                tempList.AddRange(from period in m.AvailableTimes
                                 where (period.StartTime >= rehRequest.StartTime && period.EndTime <= rehRequest.EndTime)
                                   || (period.EndTime >= rehRequest.StartTime && period.EndTime <= rehRequest.EndTime)
                                   || (period.StartTime <= rehRequest.StartTime && period.EndTime >= rehRequest.StartTime)
                                   || (period.StartTime <= rehRequest.StartTime && period.EndTime >= rehRequest.EndTime)
                                 select new AvailableTime
                                 {
                                     Id = m.Id,
                                     StartTime = new DateTime(Math.Max(period.StartTime.Ticks, rehRequest.StartTime.Ticks)),
                                     EndTime = new DateTime(Math.Min(period.EndTime.Ticks, rehRequest.EndTime.Ticks))
                                 });
            }

            //filter: min duration
            tempList = tempList.FindAll(at => (at.EndTime - at.StartTime).TotalHours >= rehRequest.Duration);

            //filter: only where all have time

            foreach (AvailableTime aT in tempList.FindAll(time => time.Id == currentBand.Leader.Id)) //loop through all fitting aTs of Leader
            {
                //calc if all other musicians have their time too, if yes: return dateTime
                AvailableTime calcedAvailableTime = calcOverlappingDateTimeOfAllMusicians(aT, tempList);

                if (calcedAvailableTime != null && ((calcedAvailableTime.EndTime - calcedAvailableTime.StartTime).TotalHours >= rehRequest.Duration))
                {
                    retList.Add(calcedAvailableTime);
                }
            }

            return retList;
        }
コード例 #3
0
        private void btnCreateNewRehearsal_Click(object sender, RoutedEventArgs e)
        {
            RehearsalRequest rehRequest = new RehearsalRequest();

            try
            {
                rehRequest.StartTime = this.dtpNewReharsalStart.Value.Value;
                rehRequest.EndTime = this.dtpNewReharsalEnd.Value.Value;
                rehRequest.Duration = Double.Parse(this.tbNewRehearsalDuration.Text);

                if (rehRequest.StartTime != null && rehRequest.EndTime != null)
                {
                    //insert request and add to band
                    rehRequest.Id = WebserviceManager.AddRehearsalRequest(currentBand, rehRequest);

                    this.currentBand.RehearsalRequests.Add(rehRequest);
                    this.dgRehearsalRequests.Items.Refresh();
                }
            }
            catch (Exception)
            {
                this.printError("Felder nicht korrekt ausgefüllt!");
            }
        }
コード例 #4
0
        public static int AddRehearsalRequest(Band b, RehearsalRequest rehRequest)
        {
            AddBandWrapper abWrapper = new AddBandWrapper(b, rehRequest);
            WebResponse resp = POST(Uri + "/rest/bands/rehearsalRequests", JsonConvert.SerializeObject(abWrapper));

            String id = new StreamReader(resp.GetResponseStream()).ReadToEnd();
            return int.Parse(JsonConvert.DeserializeObject<String>(id));
        }