Last active
August 29, 2015 14:09
-
-
Save BryanWilhite/533aac951aea4de5f7c2 to your computer and use it in GitHub Desktop.
C#, Silverlight/Telerik: RiaOperationForAdminUomDepartments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Sample | |
{ | |
#region AdminUomDepartments: | |
void DoRiaOperationForAdminUomDepartments(ReadOnlyCollection<Entity> added, | |
ReadOnlyCollection<Entity> modified, ReadOnlyCollection<Entity> removed) | |
{ | |
if (added.OfType<UOM>().Count() > 0) | |
{ | |
this.DoRiaOperationForAdminUomDepartmentsAdded(added.OfType<UOM>()); | |
} | |
if (modified.OfType<UOM>().Count() > 0) | |
{ | |
this.DoRiaOperationForAdminUomDepartmentsModified(modified.OfType<UOM>()); | |
} | |
if (removed.OfType<UOM>().Count() > 0) | |
{ | |
this.DoRiaOperationForAdminUomDepartmentsRemoved(removed.OfType<UOM>()); | |
} | |
} | |
void DoRiaOperationForAdminUomDepartmentsAdded(IEnumerable<UOM> data) | |
{ | |
if (!this._adminUoMDepartments.ContainsKey(0)) return; | |
var entityAdded = data.First().ToMenuItemDatum(); | |
var departments = this._adminUoMDepartments[0] | |
.OfType<MenuItemDatum>() | |
.Select(i => i.GetDeepCopy()).ToArray(); | |
entityAdded.ChildItems = departments; | |
this.DoRiaOperationForManyToManyRelations("UoM", new MenuItemDatum[] { entityAdded }); | |
this._adminUoMDepartments.Add(entityAdded.Id, this._adminUoMDepartments[0]); | |
this._adminUoMDepartments.Remove(0); | |
} | |
void DoRiaOperationForAdminUomDepartmentsModified(IEnumerable<UOM> data) | |
{ | |
var list = data.Select(i => | |
{ | |
var m = i.ToMenuItemDatum(); | |
var departments = this._adminUoMDepartments[m.Id]; | |
m.ChildItems = departments.OfType<MenuItemDatum>().ToArray(); | |
return m; | |
}).ToList(); | |
this.DoRiaOperationForManyToManyRelations("UoM", list); | |
} | |
void DoRiaOperationForAdminUomDepartmentsRemoved(IEnumerable<UOM> data) | |
{ | |
var list = data.Select(i => i.ToMenuItemDatum()).ToList(); | |
this.DoRiaOperationForManyToManyRelations("UoM", list); | |
} | |
#endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment