void ObjectsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Remove) { try { foreach (object item in e.OldItems) { CompanyViewModel UIObject = item as CompanyViewModel; CompaniesDataAccess.DeleteObject(UIObject.GetDataObject()); } } catch (Exception ex) { log.Error(ex.StackTrace); } } }
public CompaniesCollectionViewModel GetObjects() { UIObjects = new CompaniesCollectionViewModel(); List <Company> dataObjects = CompaniesDataAccess.GetObjects(); foreach (Company dataObject in dataObjects) { UIObjects.Add(new CompanyViewModel(dataObject)); } if (UIObjects.Count == 0) { UIObjects.Add(new CompanyViewModel()); } UIObjects.ItemEndEdit += new ItemEndEditEventHandler(ObjectsItemEndEdit); UIObjects.CollectionChanged += new NotifyCollectionChangedEventHandler(ObjectsCollectionChanged); return(UIObjects); }
void ObjectsItemEndEdit(IEditableObject sender) { CompanyViewModel UIObject = sender as CompanyViewModel; try { if (UIObject.Name != null) { int id = CompaniesDataAccess.UpdateObject(UIObject.GetDataObject()); if (id != -1) { UIObject.Id = id; } } } catch { UIObjects.Remove(UIObject); RadWindow.Alert(new DialogParameters { Content = MessageUtil.FormatMessage("ERROR.DuplicatedEntry", UIObject.Name, UIObject.Case) }); } }
public VesselService(VesselsDataAccess vesselsDataAccess, CompaniesDataAccess companiesDataAccess, UsersDataAccess usersDataAccess) { _vesselsDataAccess = vesselsDataAccess; _companiesDataAccess = companiesDataAccess; _usersDataAccess = usersDataAccess; }
public CompanyService(CompaniesDataAccess companiesDataAccess) { _companiesDataAccess = companiesDataAccess; }