public ActionResult Create(ProjectCreateViewModel model) { if (!ModelState.IsValid) return View(model); var owner = new ApplicationUser() { Id = User.Identity.GetUserId() }; Project project = new Project(model) { Owner = owner }; var initialAuth = new ProjectAuthorization { Project = project, User = owner, Permission = Permission.Administrator }; db.Entry(owner).State = EntityState.Unchanged; db.Entry(project).State = EntityState.Added; db.Entry(initialAuth).State = EntityState.Added; db.SaveChanges(); return RedirectToAction("Index"); }
public ProjectAuthorization(ApplicationUser _user, Project _project, Permission _permission) { User = _user; Project = _project; Permission = _permission; }
public ProjectViewModel(Project project) { Id = project.Id; Name = project.Name; Description = project.Description; Owner = project.Owner; }
public Project ToProject() { Project project = new Project(); project.Id = Id; project.Name = Name; project.Description = Description; return project; }