public ActionResult Edit(int id) { PatternService service = new PatternService(); PatternEditViewModel patternEditViewModel = service.GetEditViewModel(id); return(PartialView(patternEditViewModel)); }
public PatternEditViewModel GetEditViewModel(int patternId) { EntityService entityService = new EntityService(); Pattern pattern = this.FirstOrDefault(q => q.Id == patternId); List <Entity> entities = entityService.GetAll(); PatternEditViewModel model = new PatternEditViewModel(); model.AllEntities = entities; model.SelectedEntities = pattern.PatternEntityMappings .Where(q => q.Active == true) .OrderBy(q => q.Position) .Select(q => new Entity() { Id = q.EntityId.Value, Name = q.Entity.Name, Words = q.Entity.Words }) .ToList(); model.Id = pattern.Id; model.MatchBegin = pattern.MatchBegin; model.MatchEnd = pattern.MatchEnd; model.Name = pattern.Name; return(model); }