Пример #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 Project(ProjectCreateViewModel model)
 {
     Name = model.Name;
     Description = model.Description;
 }