Ejemplo n.º 1
0
 public ActionResult <IEnumerable <Keep> > Get()
 {
     try
     {
         return(Ok(_ks.Get()));
     }
     catch (Exception e) { return(BadRequest(e.Message)); }
 }
Ejemplo n.º 2
0
 public ActionResult <IEnumerable <Keep> > Get()
 {
     try
     {
         return(Ok(_kService.Get()));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
Ejemplo n.º 3
0
        [Fact] //Checks if Get returns List<Keep>
        public void CanGetResults()
        {
            moqKeepsRepository.Setup(repo => repo.Get()).Returns(new List <Keep>());

            var result = keepsService.Get();

            Assert.Equal(new List <Keep>(), result);
        }
Ejemplo n.º 4
0
 public ActionResult <IEnumerable <Keep> > Get(int id)
 {
     try
     {
         return(Ok(_kserv.Get(id)));
     }
     catch (Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
Ejemplo n.º 5
0
 [HttpGet]                                       //Get All api/keeps
 public ActionResult <IEnumerable <Keep> > Get() //TODO somehow gotta make this also get private ones if youre the poster
 {
     try
     {
         return(Ok(_ks.Get()));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     };
 }
Ejemplo n.º 6
0
 public ActionResult <Keep> Get(int id)
 {
     try
     {
         return(Ok(_ks.Get(id)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        [TestMethod] //Checks if Get returns List<Keep>
        public void CanGetResults()
        {
            var list = new List <Keep>();

            moqKeepsRepository.Setup(repo => repo.Get()).Returns(list);

            var result = keepsService.Get();

            moqKeepsRepository.Verify(repo => repo.Get());
            Assert.AreEqual(list, result);
        }
Ejemplo n.º 8
0
 public ActionResult <IEnumerable <Keep> > Get()
 {
     try
     {
         // var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         return(Ok(_ks.Get()));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     };
 }
Ejemplo n.º 9
0
        public ActionResult <VaultKeep> Create([FromBody] VaultKeep newVKeep)
        {
            string reqUserId = HttpContext.User.FindFirstValue("Id");
            User   user      = _as.GetUserById(reqUserId);

            newVKeep.UserId = user.Id;
            //Check if vault is owned by user
            newVKeep.VaultId = _vs.Get(newVKeep.VaultId, newVKeep.UserId).Id;
            //Check if keep exists
            newVKeep.KeepId = _ks.Get(newVKeep.KeepId).Id;
            //Post to vk repo
            return(Ok(_vks.Create(newVKeep)));
        }