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); ReplaceItemHandler handler = OnReplacedListingItem; if (handler != null) { handler(this, new ListingItemArgs(oldItem)); } 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; Localities.Add(locality); return(newItem); }
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); }
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; Localities.Add(locality); return(newItem); }