コード例 #1
0
        //Delete
        public ActionResult Delete(int id)
        {
            ProjectsRepo projectsRepo = new ProjectsRepo();

            Project item = projectsRepo.GetById(id);

            projectsRepo.Delete(item);

            return(RedirectToAction("Index", "Projects"));
        }
コード例 #2
0
        public ActionResult Edit(int?id)
        {
            ProjectsRepo repo = new ProjectsRepo();

            // If id is null, a new project is created.
            // Otherwise the project is extracted from the repo.
            Project item = id == null ?
                           new Project() :
                           repo.GetById(id.Value);

            // Extraction of the project data from the database.
            EditM model = new EditM
            {
                Id          = item.Id,
                Name        = item.Name,
                Description = item.Description,
                Client      = item.Client
            };

            return(View(model));
        }