Ejemplo n.º 1
0
        public async Task <ActionResult <Response <ResponseList <object> > > > GetSalaryInMonth()
        {
            var token     = HttpContext.Request.Headers["Authorization"].FirstOrDefault();
            var userToken = token.Split(' ')[1];
            var user      = UserToken.FromToken(userToken);

            var houresInMonth = await _workDayService.GetSalaryInMonth(user.UserId);

            return(Ok(HelperBox.DataToResponse <HouresInMonthResponse>(true, new HouresInMonthResponse()
            {
                HouresList = new ResponseList <object>()
                {
                    List = houresInMonth.Data,
                    Count = houresInMonth.Data.Count(),
                },
                Keys = houresInMonth.Keys
            })));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> UpdateProduct(int productShopId, [FromBody] ProductRequest productRequest)
        {
            var product = await _productService.UpdateProduct(productShopId, productRequest.ShopId);

            if (product == null)
            {
                return(BadRequest(HelperBox.DataToResponse <object>(false, null, "winkel niet gevonden")));
            }
            var token     = HttpContext.Request.Headers["Authorization"].FirstOrDefault();
            var userToken = token.Split(' ')[1];
            var user      = UserToken.FromToken(userToken);

            var shoppingGroup = await _shoppingGroupService.GetActiveShoppingGroupByUserId(user.UserId);

            await _shoppingListHub.Clients.Group(shoppingGroup.Id.ToString()).SendAsync(nameof(IMyShoppingListHub.UpdateProduct), productRequest.ShopId, product);

            return(Ok(HelperBox.DataToResponse(true, "Product is geupdate aan de winkel")));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> MoveProduct([FromBody] MoveProductRequest moveProductRequest)
        {
            var success = await _productService.MoveProduct(moveProductRequest);

            if (!success)
            {
                return(BadRequest(HelperBox.DataToResponse <string>(false, null, "Product is niet gevonden")));
            }

            var token     = HttpContext.Request.Headers["Authorization"].FirstOrDefault();
            var userToken = token.Split(' ')[1];
            var user      = UserToken.FromToken(userToken);

            var shoppingGroup = await _shoppingGroupService.GetActiveShoppingGroupByUserId(user.UserId);

            await _shoppingListHub.Clients.Group(shoppingGroup.Id.ToString()).SendAsync(nameof(IMyShoppingListHub.MoveProduct), moveProductRequest.OldShopId, moveProductRequest.NewShopId, moveProductRequest.ShopProductId);

            return(Ok(HelperBox.DataToResponse(true, "Product is verplaatst")));
        }