Exemplo n.º 1
0
        public async Task <ActionResult <VaultKeep> > CreateAsync([FromBody] VaultKeep newVaultKeep)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                newVaultKeep.CreatorId = userInfo.Id;
                return(Ok(_service.Create(newVaultKeep)));
            }
            catch (System.Exception err)
            {
                return(BadRequest(err.Message));
            }
        }
Exemplo n.º 2
0
        public ActionResult <VaultKeep> Post([FromBody] VaultKeep newVaultKeep)
        {
            try
            {
                var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
                newVaultKeep.UserId = userId;

                return(Ok(_vks.Create(newVaultKeep)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            };
        }
Exemplo n.º 3
0
        public async Task <ActionResult <VaultKeep> > Create(VaultKeep newVaultKeep)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                newVaultKeep.CreatorId = userInfo.Id;
                VaultKeep created = _vks.Create(newVaultKeep);
                created.Creator = userInfo;
                return(Ok(created));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Exemplo n.º 4
0
 public ActionResult <Keep> Create([FromBody] VaultKeep relationship)
 {
     try
     {
         Claim user = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         if (user == null)
         {
             throw new Exception("You must be logged in to add a keep to a vault.");
         }
         relationship.UserId = user.Value;
         return(Ok(_service.Create(relationship)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
Exemplo n.º 5
0
        public async Task <ActionResult <Keep> > Create([FromBody] VaultKeep newVaultKeep)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                newVaultKeep.CreatorId = userInfo.Id;
                var result = _vks.Create(newVaultKeep);
                if (result != null)
                {
                    return(Ok(result));
                }
                return(BadRequest());
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }