コード例 #1
0
        public IActionResult Create()
        {
            var collaboratorModel = new CollaboratorModel();

            collaboratorModel.FillItems(_dataManager);
            return(View("EditCollaborator", collaboratorModel));
        }
コード例 #2
0
        public IActionResult Edit(CollaboratorModel collaboratorModel)
        {
            if (!ModelState.IsValid)
            {
                collaboratorModel.FillItems(_dataManager);
                return(View("EditCollaborator", collaboratorModel));
            }
            var collaborator = new Collaborator();

            if (collaboratorModel.Id != null)
            {
                collaborator = _dataManager.CollaboratorRepository.GetById(collaboratorModel.Id.Value);
            }
            collaboratorModel.ApplyChanges(collaborator);

            _dataManager.CollaboratorRepository.Update(collaborator);
            _dataManager.SaveChanges();

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