//edit developer public ActionResult Edit(int DeveloperId)//to find the developer { //find the developer Developer developer = context.Find(DeveloperId); if (developer == null) { return(HttpNotFound()); } else { DeveloperManagerViewModel ViewModel = new DeveloperManagerViewModel(); ViewModel.Developer = developer; ViewModel.DeveloperId = DeveloperId; ViewModel.DeveloperPositions = developerPositions.Collection(); //Get developers potential supervisors from the database based on his role using (var dbContext = new DataContext()) { //3 Cases if (developer.Position == "Developer") { var potentialSuperiorsList = dbContext.Developers .SqlQuery("SELECT * FROM [StaffPositions].[dbo].[Developers] where Position = 'Team Lead' ORDER BY FullName ASC") .ToList <Developer>(); ViewModel.PotentialSuperiors = potentialSuperiorsList; } else if (developer.Position == "Team Lead") { var potentialSuperiorsList = dbContext.Developers .SqlQuery("SELECT * FROM [StaffPositions].[dbo].[Developers] where Position = 'Manager' ORDER BY FullName ASC") .ToList <Developer>(); ViewModel.PotentialSuperiors = potentialSuperiorsList; } else //Manager has no superior { List <Developer> potentialSuperiorsList = new List <Developer>(); potentialSuperiorsList.Add(new Developer { FirstName = "aaa", LastName = "aaa", FullName = "Not Supervised", Email = "*****@*****.**", Position = "aaa", Photo = "aaa", DeveloperId = 1000, SuperiorID = 10000, SuperiorName = "Not Supervised" }); ViewModel.PotentialSuperiors = potentialSuperiorsList; } } return(View(ViewModel)); } }
//create developer details view public ActionResult Details(int DeveloperId) { Developer developer = context.Find(DeveloperId); if (developer == null) { return(HttpNotFound()); } else { return(View(developer)); } }
public async Task <IActionResult> GetDevelopers([FromRoute] int id) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Developers developers = await _developerRepostiory.Find(id); if (developers == null) { return(NotFound()); } return(Ok(developers)); } catch (Exception ex) { return(new StatusCodeResult(500)); } }