public IActionResult AddService(AddServiceCommand serviceToAdd, string inmateName) { var repo = new InmateRepository(); repo.AddService(serviceToAdd.Service, inmateName); return(Created($"api/inmates/{inmateName}/services/{serviceToAdd}", serviceToAdd)); }
public ActionResult <IEnumerable <string> > GetMyFriendFriends(string myFriend) { var inmateRepo = new InmateRepository(); var friends = inmateRepo.GetFriends(myFriend); return(Ok(friends)); }
public ActionResult <IEnumerable <string> > GetFriendsByName(string inmateName) { var repo = new InmateRepository(); var allFriends = repo.GetAllFriends(inmateName); return(Ok(allFriends)); }
public IActionResult UpdateInterests(string name, UpdateInterestCommand newInterest) { var repo = new InmateRepository(); var newCriminalInterest = repo.UpdateInterest(name, newInterest.CriminalInterest); return(Ok(newCriminalInterest)); }
public ActionResult <List <string> > GetServicesByInmate(string inmateName) { var repo = new InmateRepository(); var allServices = repo.GetServices(inmateName); return(Ok(allServices)); }
public IActionResult UpdateInmateInterest(UpdateInterestCommand updateInterestCommand, int id) { var repo = new InmateRepository(); var inmateInterestGotUpdated = repo.updateInmateInterest(updateInterestCommand.Interests, id); return(Ok(inmateInterestGotUpdated)); }
public IEnumerable <Inmate> UpdateServices(string name, string serviceToUpdate, UpdateServiceCommand newService) { var repo = new InmateRepository(); var services = repo.UpdateService(name, serviceToUpdate, newService); var allInmates = repo.GetAll(); return(allInmates); }
public IActionResult AddNewFriend(AddFriendCommand friendToAdd, string name) { var repo = new InmateRepository(); string friendName = friendToAdd.Name; var friendCriminalInterest = friendToAdd.CriminalInterest; repo.AddNewFriend(friendName, name); return(Created($"api/inmates/{friendToAdd.Name}", friendToAdd)); }
public IActionResult AddNewEnemy(AddEnemyCommand enemyToAdd, string name) { var repo = new InmateRepository(); string enemyName = enemyToAdd.Name; var enemyCriminalInterest = enemyToAdd.CriminalInterest; repo.AddNewEnemy(enemyName, name); return(Created($"api/inmates/{enemyToAdd.Name}", enemyToAdd)); }
public ActionResult <IEnumerable <string> > BuildCrew(BuildCrewCommand crewToAdd, string name) { var repo = new InmateRepository(); _ = new List <string>(); List <string> myCrew = crewToAdd.MyFriends; var friends = repo.AddCrew(myCrew, name); return(Ok(friends)); }
public ActionResult <int> GetDaysLeftInSentence(int id) { var repo = new InmateRepository(); var inmate = repo.Get(id); var today = DateTime.Now; TimeSpan daysServed = inmate.ConvictedDate - today; var daysServedAbs = Math.Abs(daysServed.Days); var daysLeft = (inmate.LengthOfSentence - daysServedAbs); return(daysLeft); }
public ActionResult <IEnumerable <string> > GetMyFriends(int id) { try { var repo = new InmateRepository(); var myFriends = repo.GetMyFriends(id); return(myFriends); } catch (Exception) { return(BadRequest("Inmate ID does not exist")); } }
public ActionResult <List <string> > GetMyCrews(int id) { try { var repo = new InmateRepository(); var myCrews = repo.GetFriendsFriend(id); return(myCrews); } catch (Exception) { return(BadRequest("Inmate ID does not exist")); } }
public IActionResult CreateInmate(CreateInmateCommand newInmateCommand) { var newInmate = new Inmate { Id = Guid.NewGuid(), FirstName = newInmateCommand.FirstName, LastName = newInmateCommand.LastName, ReleaseDate = newInmateCommand.ReleaseDate, Budget = newInmateCommand.Budget, }; var repo = new InmateRepository(); var inmateThatGotCreated = repo.Create(newInmate); return(Created($"api/inmate/{inmateThatGotCreated.FirstName}{inmateThatGotCreated.LastName}", inmateThatGotCreated)); }
public IActionResult CreateInmate(AddInmateCommand newAddInmateCommand) { var newInmate = new Inmate { Id = Guid.NewGuid(), Name = newAddInmateCommand.Name, Location = newAddInmateCommand.Location, CriminalInterest = newAddInmateCommand.CriminalInterest, ReleaseDate = newAddInmateCommand.ReleaseDate, }; var repo = new InmateRepository(); var inmateThatGotCreated = repo.Add(newInmate); return(Created($"api/inmates/{inmateThatGotCreated.Name}", inmateThatGotCreated)); }
public void getEnemiesByInmateIdReturnsAListOfEnemies() { // Arrange var inmateRepository = new InmateRepository(); List <Inmate> result = new List <Inmate>(); // Act List <Inmate> inmate1EnemiesFromMethod = inmateRepository.GetEnemiesByInmateId(new Guid("00000000-0000-0000-0000-000000000001")); Inmate inmate3 = inmateRepository.GetInmateById(new Guid("00000000-0000-0000-0000-000000000003")); Inmate inmate9 = inmateRepository.GetInmateById(new Guid("00000000-0000-0000-0000-000000000009")); Inmate inmate12 = inmateRepository.GetInmateById(new Guid("00000000-0000-0000-0000-000000000012")); result.Add(inmate3); result.Add(inmate9); result.Add(inmate12); // Assert Assert.Equal(inmate1EnemiesFromMethod, result); }
public IActionResult UpdateInmate(UpdateInmateCommand updatedInmateCommand, int id) { var repo = new InmateRepository(); var updatedInmate = new Inmate { Name = updatedInmateCommand.Name, ConvictedDate = updatedInmateCommand.ConvictetdDate, LengthOfSentence = updatedInmateCommand.LenghtOfSentence, CrimeCharged = updatedInmateCommand.CrimeCharged, Crew = updatedInmateCommand.Crew, Clique = updatedInmateCommand.Clique, Beefs = updatedInmateCommand.Beefs, Interests = updatedInmateCommand.Interests, }; var inmateThatGotUpdated = repo.Update(updatedInmate, id); return(Ok(inmateThatGotUpdated)); }
public IActionResult CreateInmate(AddInmateCommand newInmateCommand) { var newInmate = new Inmate { id = newInmateCommand.id, Name = newInmateCommand.Name, ConvictedDate = newInmateCommand.ConvictedDate, LengthOfSentence = newInmateCommand.LengthOfSentence, CrimeCharged = newInmateCommand.CrimeCharged, Crew = newInmateCommand.Crew, Clique = newInmateCommand.Clique, Beefs = newInmateCommand.Beefs, Interests = newInmateCommand.Interests, }; var repo = new InmateRepository(); var inmateThatGotCreated = repo.Add(newInmate); return(Created($"api/Inmate/{inmateThatGotCreated.Name}", inmateThatGotCreated)); }
public ActionResult <IEnumerable <Inmate> > GetAllInmates() { var repo = new InmateRepository(); return(repo.GetAll()); }
public ActionResult <IEnumerable <Inmate> > GetEnemiesByInmateId(Guid inmateId) { var repo = new InmateRepository(); return(repo.GetEnemiesByInmateId(inmateId)); }
public ActionResult <IEnumerable <Inmate> > GetByCriminalInterest(CriminalInterest criminalInterestToSearchFor) { var inmateRepo = new InmateRepository(); return(inmateRepo.Get(criminalInterestToSearchFor)); }
public ActionResult <IEnumerable <Inmate> > GetListOfInmatesByInterest(string interest) { var repo = new InmateRepository(); return(Ok(repo.GetListOfInmatesByInterest(interest))); }
public ActionResult <Inmate> GetById(int id) { var repo = new InmateRepository(); return(repo.Get(id)); }
public ActionResult <int> GetDaysUntilRelease(string name) { var repo = new InmateRepository(); return(Ok(repo.GetDaysUntilRelease(name))); }