コード例 #1
0
        public IActionResult AddService(AddServiceCommand serviceToAdd, string inmateName)
        {
            var repo = new InmateRepository();

            repo.AddService(serviceToAdd.Service, inmateName);
            return(Created($"api/inmates/{inmateName}/services/{serviceToAdd}", serviceToAdd));
        }
コード例 #2
0
        public ActionResult <IEnumerable <string> > GetMyFriendFriends(string myFriend)
        {
            var inmateRepo = new InmateRepository();
            var friends    = inmateRepo.GetFriends(myFriend);

            return(Ok(friends));
        }
コード例 #3
0
        public ActionResult <IEnumerable <string> > GetFriendsByName(string inmateName)
        {
            var repo       = new InmateRepository();
            var allFriends = repo.GetAllFriends(inmateName);

            return(Ok(allFriends));
        }
コード例 #4
0
        public IActionResult UpdateInterests(string name, UpdateInterestCommand newInterest)
        {
            var repo = new InmateRepository();
            var newCriminalInterest = repo.UpdateInterest(name, newInterest.CriminalInterest);

            return(Ok(newCriminalInterest));
        }
コード例 #5
0
        public ActionResult <List <string> > GetServicesByInmate(string inmateName)
        {
            var repo        = new InmateRepository();
            var allServices = repo.GetServices(inmateName);

            return(Ok(allServices));
        }
コード例 #6
0
        public IActionResult UpdateInmateInterest(UpdateInterestCommand updateInterestCommand, int id)
        {
            var repo = new InmateRepository();

            var inmateInterestGotUpdated = repo.updateInmateInterest(updateInterestCommand.Interests, id);

            return(Ok(inmateInterestGotUpdated));
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        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));
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        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);
        }
コード例 #12
0
 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"));
     }
 }
コード例 #13
0
 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"));
     }
 }
コード例 #14
0
        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));
        }
コード例 #15
0
        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));
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        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));
        }
コード例 #18
0
        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));
        }
コード例 #19
0
        public ActionResult <IEnumerable <Inmate> > GetAllInmates()
        {
            var repo = new InmateRepository();

            return(repo.GetAll());
        }
コード例 #20
0
        public ActionResult <IEnumerable <Inmate> > GetEnemiesByInmateId(Guid inmateId)
        {
            var repo = new InmateRepository();

            return(repo.GetEnemiesByInmateId(inmateId));
        }
コード例 #21
0
        public ActionResult <IEnumerable <Inmate> > GetByCriminalInterest(CriminalInterest criminalInterestToSearchFor)
        {
            var inmateRepo = new InmateRepository();

            return(inmateRepo.Get(criminalInterestToSearchFor));
        }
コード例 #22
0
        public ActionResult <IEnumerable <Inmate> > GetListOfInmatesByInterest(string interest)
        {
            var repo = new InmateRepository();

            return(Ok(repo.GetListOfInmatesByInterest(interest)));
        }
コード例 #23
0
        public ActionResult <Inmate> GetById(int id)
        {
            var repo = new InmateRepository();

            return(repo.Get(id));
        }
コード例 #24
0
        public ActionResult <int> GetDaysUntilRelease(string name)
        {
            var repo = new InmateRepository();

            return(Ok(repo.GetDaysUntilRelease(name)));
        }