public IActionResult Create() { var collaboratorModel = new CollaboratorModel(); collaboratorModel.FillItems(_dataManager); return(View("EditCollaborator", collaboratorModel)); }
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")); }