Exemple #1
0
        public ActionResult Edit(EditM model)
        {
            // Model validation.
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // Extraction of the inputted user data.
            User item = new User
            {
                Id        = model.Id,
                Username  = model.Username,
                Password  = model.Password,
                FirstName = model.FirstName,
                LastName  = model.LastName
            };


            // Saving (inserting/updating) the user in the database.
            UsersRepo usersRepo = new UsersRepo();

            usersRepo.Save(item);

            return(RedirectToAction("Index", "Users"));
        }
Exemple #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));
        }
Exemple #3
0
        public ActionResult Edit(int?id)
        {
            UsersRepo usersRepo = new UsersRepo();

            // If id is null, a new user is created.
            // Otherwise the user is extracted from the repo.
            User user = (id == null) ?
                        new User() :
                        usersRepo.GetById(id.Value);

            // Extraction of the user data from the database.
            EditM model = new EditM
            {
                Id        = user.Id,
                Username  = user.Username,
                Password  = user.Password,
                FirstName = user.FirstName,
                LastName  = user.LastName
            };

            return(View(model));
        }
Exemple #4
0
        public ActionResult Edit(EditM model)
        {
            // Model validation.
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // Extraction of the inputted project data.
            Project item = new Project
            {
                Id          = model.Id,
                Name        = model.Name,
                Description = model.Description,
                Client      = model.Client
            };

            // Saving (inserting/updating) the project in the database.
            ProjectsRepo projectsRepo = new ProjectsRepo();

            projectsRepo.Save(item);

            return(RedirectToAction("Index", "Projects"));
        }