using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Windows.Media; using BeWo.Scheduler.Resources; using BeWo.Scheduler.View; using BeWo.ViewModel.ListViewModel; using BS.Shared; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using DevExpress.Xpf.Scheduler; using DevExpress.XtraScheduler; namespace BeWo.Scheduler.ViewModel { // EditForm für normalen Termin und EditForm für Abwesenheit/Hilfeplanende/Geburtstag // Wie ResourceAppointmentListVM aufbauen public class KlientenKalenderListVM : AbstractDCListMapperVM, ISchedulerViewModel { private List mAppointmentCategoryList; private IList mAppointmentResourceList; private readonly List mAllCustomers; private readonly List mAllEmployees; private readonly List mAllCategories; private BindingList mAppointmentList; private readonly long? mCustomerOid; private readonly List mAllSupportConcepts; public SchedulerSettings GetDefaultSchedulerSettings() { var settings = new SchedulerSettings(AppointmentKind.Customer, AppointmentViewType.WorkWeek); return settings; } public BindingList Appointments { get; private set; } public IList Categories { get; private set; } public IList Resources { get; private set; } public Dictionary>> changedOccurencyCustomFields; public object SelectedFilterObject { get; set; } void mAppointmentList_AddingNew(object sender, AddingNewEventArgs e) { var dc = new AppointmentDC { CustomerOid = mCustomerOid, EmployeeOid = BeWoApp.LoggedOnEmployee.EmployeeOid, Status = 0 }; e.NewObject = new AppointmentVM(dc); } public Dictionary>> ChangedOccurencyCustomFields { get { return changedOccurencyCustomFields; } private set { changedOccurencyCustomFields = value; } } private Dictionary oid2Category; private Dictionary catOid2Index; private readonly Dictionary> mCategories2Resources; public KlientenKalenderListVM(long? customerOid, List allCats, List allCustomers, List allemps, List appList, List allSupportConcepts) : base(appList) { mCustomerOid = customerOid; mAllCustomers = allCustomers; mAllEmployees = allemps; mAllCategories = allCats; mAllSupportConcepts = allSupportConcepts; InitViewModel(); InitChangedOccurrencyCustomFields(appList.Where(t => t.Type == 3).ToList()); } private void InitViewModel() { oid2Category = new Dictionary(); catOid2Index = new Dictionary(); mAppointmentCategoryList = new List(); mAppointmentResourceList = new List(); int index = 0; foreach (AppointmentCategoryDC item in mAllCategories) { var cat = new BeWoAppointmentCategory { CategoryObject = item, Color = ((SolidColorBrush)new BrushConverter().ConvertFrom(item.Color)).Color, DisplayName = item.DisplayName, MenuCaption = item.DisplayName }; if (!oid2Category.ContainsKey(item.AppointmentCategoryOid.Value)) oid2Category.Add(item.AppointmentCategoryOid.Value, cat); mAppointmentCategoryList.Add(cat); if (!catOid2Index.ContainsKey(item.AppointmentCategoryOid.Value)) catOid2Index.Add(item.AppointmentCategoryOid.Value, index); index++; } foreach (var item in VMList) { item.ResourceId = item.DataContract.CustomerOid; item.CustomFields.Add("EmployeeOid", item.EmployeeOid); item.CustomFields.Add("CustomerOid", item.DataContract.CustomerOid); if (item.AppointmentCategoryDC != null && oid2Category.ContainsKey(item.AppointmentCategoryDC.AppointmentCategoryOid.Value)) item.AppointmentCategory = oid2Category[item.AppointmentCategoryDC.AppointmentCategoryOid.Value]; if (item.AppointmentCategoryDC != null && catOid2Index.ContainsKey(item.AppointmentCategoryDC.AppointmentCategoryOid.Value)) item.LabelId = catOid2Index[item.AppointmentCategoryDC.AppointmentCategoryOid.Value]; } ((List)mAppointmentResourceList).Sort((a, b) => a.Caption.CompareTo(b.Caption)); } public void SaveAppointments(SchedulerControl control, IEnumerable list) { throw new NotImplementedException(); } public void DeleteAppointments(SchedulerControl control, IEnumerable list) { throw new NotImplementedException(); } public void InsertNewAppointments(SchedulerControl control, IEnumerable list) { throw new NotImplementedException(); } public AbstractAppointmentEditForm GetEditAppointmentForm(SchedulerControl control, Appointment appointment) { throw new NotImplementedException(); } public void AddCustomFieldsMapping(SchedulerStorage schedulerStorage) { throw new NotImplementedException(); } public void InitNewAppointment(Appointment appointment) { throw new NotImplementedException(); } public bool FilterAppointment(string filterCategory, object selectedObject, Appointment appointment, TimeInterval interval = null) { throw new NotImplementedException(); } public void InitChangedOccurrencyCustomFields(IEnumerable appList) where T : IDataContract { throw new NotImplementedException(); } } }