Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Task<Mapping> EditMapping(Mapping mapping)
- {
- var definitions = sites
- .FirstOrDefault(site => site.Id == mapping.SiteId)
- .MappingDefinitions;
- var modifiedDefinitions = definitions.Select(definition => {
- return definition.Mappings
- .Select(x => x.Id == mapping.Id ? mapping : x)
- .ToList();
- })
- .ToList();
- var modifiedDefinitions = definitions.Aggregate(new List<MappingDefinition>(), (mappingDefinitions, definition) => {
- definition.Mappings = definition.Mappings
- .Select(x => x.Id == mapping.Id ? mapping : x)
- .ToList();
- var exisitingDefinitions = mappingDefinitions;
- exisitingDefinitions.Add(definition);
- return exisitingDefinitions;
- });
- // Please note. Stuff like this is only because we do not have a DB to store it on
- // Our current data is a big long ass object
- sites.FirstOrDefault(site => site.Id == mapping.SiteId).MappingDefinitions = modifiedDefinitions;
- return Task.FromResult(mapping);
- }
- public
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement