예제 #1
0
        public IActionResult Index()
        {
            var collaborators      = _dataManager.CollaboratorRepository.GetAll();
            var collaboratorModels = new List <CollaboratorModel>();

            foreach (var a in collaborators)
            {
                var collaboratorModel = new CollaboratorModel();
                collaboratorModel.SetModel(a, _dataManager);
                collaboratorModels.Add(collaboratorModel);
            }

            return(View(collaboratorModels));
        }
        public IActionResult Edit(int id)
        {
            var collaborator = _dataManager.CollaboratorRepository.GetById(id);

            if (collaborator == null)
            {
                return(NotFound());
            }

            var collaboratorModel = new CollaboratorModel();

            collaboratorModel.SetModel(collaborator, _dataManager);

            return(View("EditCollaborator", collaboratorModel));
        }
예제 #3
0
        public IActionResult SearchCollaborators(string searchValue)
        {
            if (string.IsNullOrEmpty(searchValue))
            {
                return(RedirectToAction("Index"));
            }

            searchValue = searchValue.ToLower();
            var collaborators = _dataManager.CollaboratorRepository.GetAll()
                                .Where(x => x.FirstName.ToLower() == searchValue ||
                                       x.SecondName.ToLower() == searchValue ||
                                       x.MiddleName.ToLower() == searchValue);

            var collaboratorModels = new List <CollaboratorModel>();

            foreach (var a in collaborators)
            {
                var collaboratorModel = new CollaboratorModel();
                collaboratorModel.SetModel(a, _dataManager);
                collaboratorModels.Add(collaboratorModel);
            }

            return(View("Index", collaboratorModels));
        }