예제 #1
0
        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");
        }
예제 #2
0
 public ProjectAuthorization(ApplicationUser _user, Project _project, Permission _permission)
 {
     User = _user;
     Project = _project;
     Permission = _permission;
 }
예제 #3
0
 public ProjectViewModel(Project project)
 {
     Id = project.Id;
     Name = project.Name;
     Description = project.Description;
     Owner = project.Owner;
 }
예제 #4
0
 public Project ToProject()
 {
     Project project = new Project();
     project.Id = Id;
     project.Name = Name;
     project.Description = Description;
     return project;
 }