예제 #1
0
파일: Listing.cs 프로젝트: blitzik/Evidoo
        public ListingItem ReplaceItem(int day, string locality, Time start, Time end, Time lunchStart, Time lunchEnd, Time otherHours)
        {
            if (!_items.ContainsKey(day))
            {
                return(AddItem(day, locality, start, end, lunchStart, lunchEnd, otherHours));
            }

            ListingItem oldItem = GetItemByDay(day);

            ListingItem newItem = new ListingItem(this, day, locality, start, end, lunchStart, lunchEnd, otherHours);

            WorkedHours      += newItem.TimeSetting.WorkedHours - oldItem.TimeSetting.WorkedHours;
            LunchHours       += newItem.TimeSetting.LunchHours - oldItem.TimeSetting.LunchHours;
            OtherHours       += newItem.TimeSetting.OtherHours - oldItem.TimeSetting.OtherHours;
            TotalWorkedHours += newItem.TimeSetting.TotalWorkedHours - oldItem.TimeSetting.TotalWorkedHours;

            _items[day] = newItem;

            if (!string.IsNullOrEmpty(newItem.Locality))
            {
                Localities.Add(locality);
            }

            return(newItem);
        }
예제 #2
0
파일: Listing.cs 프로젝트: blitzik/Evidoo
        public void RemoveItemByDay(int day)
        {
            if (!_items.ContainsKey(day))
            {
                return;
            }

            ListingItem item = _items[day];

            WorkedDays--;
            WorkedHours      -= item.TimeSetting.WorkedHours;
            LunchHours       -= item.TimeSetting.LunchHours;
            OtherHours       -= item.TimeSetting.OtherHours;
            TotalWorkedHours -= item.TimeSetting.TotalWorkedHours;

            _items.Remove(day);
        }
예제 #3
0
파일: DayItem.cs 프로젝트: blitzik/Evidoo
        public DayItem(Listing listing, int day)
        {
            _listing = listing;
            _year    = listing.Year;
            _month   = listing.Month;
            _day     = day;
            _date    = new DateTime(_year, _month, day);
            _week    = PrepareWeek(_year, _month, _day);

            ListingItem item = listing.GetItemByDay(day);

            if (item != null)
            {
                _listingItem = item;
                Locality     = item.Locality;
                _timeSetting = item.TimeSetting;
            }
        }
예제 #4
0
파일: DayItem.cs 프로젝트: blitzik/Evidoo
        public void Update(ListingItem item)
        {
            ArgumentException e = new ArgumentException();

            if (!Listing.ContainsItem(item))
            {
                throw e;
            }

            if (item.Date.Day != Day)
            {
                throw e;
            }

            ListingItem = item;

            Locality    = item.Locality;
            TimeSetting = item.TimeSetting;

            NotifyPropertiesChanged();
        }
예제 #5
0
파일: Listing.cs 프로젝트: blitzik/Evidoo
        public ListingItem AddItem(int day, string locality, Time start, Time end, Time lunchStart, Time lunchEnd, Time otherHours)
        {
            if (_items.ContainsKey(day))
            {
                throw new ListingItemAlreadyExistsException();
            }

            ListingItem newItem = new ListingItem(this, day, locality, start, end, lunchStart, lunchEnd, otherHours);

            _items.Add(day, newItem);
            WorkedDays++;
            WorkedHours      += newItem.TimeSetting.WorkedHours;
            LunchHours       += newItem.TimeSetting.LunchHours;
            OtherHours       += newItem.TimeSetting.OtherHours;
            TotalWorkedHours += newItem.TimeSetting.TotalWorkedHours;

            if (!string.IsNullOrEmpty(newItem.Locality))
            {
                Localities.Add(locality);
            }

            return(newItem);
        }
예제 #6
0
파일: Listing.cs 프로젝트: blitzik/Evidoo
 public bool ContainsItem(ListingItem item)
 {
     return(_items.Contains(new KeyValuePair <int, ListingItem>(item.Day, item)));
 }