public async Task <ActionResult <ConsumableViewResource> > PostAction([FromServices] IPost post, [FromBody] ConsumableViewResource consume)
 {
     HeaderDecode.DecodeHeader(Request);
     log.LogInformation($"Adding {consume.Name} to consumable resources");
     return(await TryTask <ConsumableViewResource> .Run(async() =>
     {
         await post.AddConsumable(consume);
         return consume;
     }));
 }
Beispiel #2
0
        public async Task <ActionResult <IEnumerable <UsersView> > > GetActionUserName([FromServices] IGet get)
        {
            string[] authorization = await HeaderDecode.DecodeHeader(Request);

            string token = authorization[0], pwd = authorization[1];

            log.LogInformation($"Querrying the database for a user with the username {token}");
            var users = await get.Users(item => item.UserName.Trim() == token);

            if (BCryptHash.VerifyUser(users, pwd))
            {
                return(new ActionResult <IEnumerable <UsersView> >(users));
            }
            else
            {
                return(new ObjectResult("ERROR: Invalid username/password")
                {
                    StatusCode = 400
                });
            }
        }