public void UpdateAllPageTemplates(List <AllPageTemplatesDto> allPageTemplatesList) { using (ConsoleRepository) { foreach (var pageTemplatesDto in allPageTemplatesList) { var pageTemplate = ConsoleRepository.Query <PageTemplate>(pt => pt.Template, pt => pt.TemplatedPage, pt => pt.Team) .FirstOrDefault(pt => pt.TemplateId == pageTemplatesDto.Id); if (pageTemplate != null) { var newTemplate = ConsoleRepository.Query <Template>() .FirstOrDefault(t => t.Title == pageTemplatesDto.TemplateTitle); if (newTemplate != null) { ConsoleRepository.Attach <PageTemplate>(pageTemplate); pageTemplate.Template = newTemplate; pageTemplate.IsVisible = pageTemplatesDto.IsVisible; } } } ConsoleRepository.SaveChanges(); } }
public void SetMyUserBoolean(String propertyName, Boolean value) { User u = EnsureCurrentUser(); PropertyInfo prop = u.GetType().GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance); if (null != prop && prop.CanWrite) { //var val = Convert.ChangeType(value, prop.PropertyType); prop.SetValue(u, value, null); } _repository.Attach <User>(u); _repository.SaveChanges(); }