public ActionResult Create(CreateBlogModel model) { if (ModelState.IsValid) { var adminSecurable = new Data.Securable { Name = "Admin: " + model.Name }; _securableRepo.Create(adminSecurable); var authorSecurable = new Data.Securable { Name = "Author: " + model.Name }; _securableRepo.Create(authorSecurable); _blogRepo.Create(new Data.Blog { AdminSecurableId = adminSecurable.Id, AuthorSecurableId = authorSecurable.Id, Name = model.Name, AuthoritiveUrl = model.Url, BlogGuid = Guid.NewGuid() }); _invitationService.Invite(adminSecurable.Id, model.AdminEmail, "StaticVoid.Blog"); return(Json(new { success = true })); } return(PartialView("CreateModal", model)); }
public ActionResult EnsureBlogsHaveAuthorSecurables() { foreach (var blog in _blogRepo.GetAll().Where(b => b.AuthorSecurable == null).ToList()) { _blogAttacher.EnsureAttached(blog);//Entities must be attached to muck about with nav properties var securable = new Data.Securable(); _securableRepo.Create(securable); blog.AuthorSecurable = securable; _blogRepo.Update(blog); } return RedirectToAction("Index", "Dashboard"); }
public ActionResult EnsureBlogsHaveAuthorSecurables() { foreach (var blog in _blogRepo.GetAll().Where(b => b.AuthorSecurable == null).ToList()) { _blogAttacher.EnsureAttached(blog);//Entities must be attached to muck about with nav properties var securable = new Data.Securable(); _securableRepo.Create(securable); blog.AuthorSecurable = securable; _blogRepo.Update(blog); } return(RedirectToAction("Index", "Dashboard")); }
public ActionResult Create(CreateBlogModel model) { if (ModelState.IsValid) { var adminSecurable = new Data.Securable { Name = "Admin: " + model.Name }; _securableRepo.Create(adminSecurable); var authorSecurable = new Data.Securable { Name = "Author: " + model.Name }; _securableRepo.Create(authorSecurable); _blogRepo.Create(new Data.Blog { AdminSecurableId = adminSecurable.Id, AuthorSecurableId = authorSecurable.Id, Name = model.Name, AuthoritiveUrl = model.Url, BlogGuid = Guid.NewGuid() }); _invitationService.Invite(adminSecurable.Id, model.AdminEmail, "StaticVoid.Blog"); return Json(new { success = true }); } return PartialView("CreateModal", model); }