public ActionResult UpdateProjectInfo(long id = -1)
 {
     var project = _readOnlyRepository.GetById<ProjectEntity>(id);
     if (project != null)
     {
         var model = new NewProjectModel
         {
             ID = project.Id,
             ProjectName = project.ProjectName,
             ProjectDescription = project.ProjectDescription
         };
         return View(model);
     }
     return RedirectToAction("Index");
 }
 public ActionResult UpdateProjectInfo(NewProjectModel model)
 {
     if (ModelState.IsValid)
     {
         var project = _readOnlyRepository.FirstOrDefault<ProjectEntity>(x => x.Id == model.ID);
         if (project != null)
         {
             project.ProjectName = model.ProjectName;
             project.ProjectDescription = model.ProjectDescription;
             _writeOnlyRepository.Update(project);
             return RedirectToAction("Index");
         }
     }
     return View(model);
 }
 public ActionResult NewProject(NewProjectModel model)
 {
     if (ModelState.IsValid)
     {
         HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
         if (authCookie != null)
         {
             FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
             var user = _readOnlyRepository.FirstOrDefault<User>(x => x.Email == authTicket.UserData);
             if (user != null)
             {
                 var project = _readOnlyRepository.FirstOrDefault<ProjectEntity>(x => x.ProjectName == model.ProjectName && x.UserId == user.Id);
                 if (project == null)
                 {
                     var newProjectItem = new ProjectEntity
                     {
                         ProjectName = model.ProjectName,
                         UserId = user.Id,
                         ProjectDescription = model.ProjectDescription
                     };
                     newProjectItem = _writeOnlyRepository.Create(newProjectItem);
                     Session["CurrentViewProjectID"] = newProjectItem.Id;
                     Session["CurrentViewProjectName"] = newProjectItem.ProjectName;
                     return RedirectToAction("Index");
                 }
                 ModelState.AddModelError("", "A project with that name already exists!");
             }
         }
     }
     return View(model);
 }