Esempio n. 1
0
        public async Task <ActionResult <Response <Shop> > > CreateShop([FromBody] ShopRequest shopRequest)
        {
            var token     = HttpContext.Request.Headers["Authorization"].FirstOrDefault();
            var userToken = token.Split(' ')[1];
            var user      = UserToken.FromToken(userToken);

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

            if (String.IsNullOrWhiteSpace(shopRequest.Logo))
            {
                shopRequest.Logo = "https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse1.mm.bing.net%2Fth%3Fid%3DOIP.ZkZVmxRirz9VVcxfBZjaqQHaFD%26pid%3DApi&f=1";
            }

            var shop = await _shopService.CreateShop(shoppingGroup.Id, shopRequest);

            if (shop == null)
            {
                return(BadRequest(HelperBox.DataToResponse <Shop>(false, null, "Een winkel heeft een naam en logo nodig")));
            }
            shop.Products = new List <ProductForShop>();

            await _shoppingListHub.Clients.Group(shoppingGroup.Id.ToString()).SendAsync(nameof(IMyShoppingListHub.NewShopCreated), shop);

            return(Ok(HelperBox.DataToResponse(true, shop)));
        }
        public async Task <ActionResult <Response <ResponseList <HomeAutomation.Models.Database.MyCalender.MyCalender> > > > GetMyCalenders()
        {
            var token     = HttpContext.Request.Headers["Authorization"].FirstOrDefault();
            var userToken = token.Split(' ')[1];
            var user      = UserToken.FromToken(userToken);

            return(Ok(HelperBox.DataToReponseList(true, await _calenderService.GetCalenders(user.UserId))));
        }
Esempio n. 3
0
        public async Task <ActionResult <Response <ResponseList <ShoppingGroup> > > > GetAllMyShoppingGroups()
        {
            var token          = HttpContext.Request.Headers["Authorization"].FirstOrDefault();
            var userToken      = token.Split(' ')[1];
            var user           = UserToken.FromToken(userToken);
            var shoppingGroups = await _shoppingGroupService.GetAllShoppingGroupsByUserId(user.UserId);

            return(Ok(HelperBox.DataToReponseList(true, shoppingGroups)));
        }
        public async Task <ActionResult <Response <SearchResponse> > > SearchCalender([FromBody] SearchRequest searchSettings)
        {
            var response = await _calenderService.Search(searchSettings);

            if (response == null)
            {
                return(BadRequest(HelperBox.DataToResponse <string>(false, null, "Er moet minimaal een searchString mee worden gegeven")));
            }
            return(Ok(HelperBox.DataToResponse(true, response)));
        }
        public async Task <ActionResult <Response <WorkDay> > > CreateWorkDay([FromBody] WorkDay workDayData)
        {
            var token     = HttpContext.Request.Headers["Authorization"].FirstOrDefault();
            var userToken = token.Split(' ')[1];
            var user      = UserToken.FromToken(userToken);

            var workDay = await _workDayService.CreateWorkDay(user.UserId, workDayData);

            return(Ok(HelperBox.DataToResponse(true, workDay)));
        }
        public async Task <ActionResult <Response <ResponseList <WorkDay> > > > GetWorkDays()
        {
            var token     = HttpContext.Request.Headers["Authorization"].FirstOrDefault();
            var userToken = token.Split(' ')[1];
            var user      = UserToken.FromToken(userToken);

            var workDays = await _workDayService.GetWorkDays(user.UserId);

            return(Ok(HelperBox.DataToReponseList(true, workDays)));
        }
Esempio n. 7
0
        public async Task <IActionResult> SetActiveShoppingGroup([FromBody] ShoppingGroupRequest shoppingGroupRequest)
        {
            var token     = HttpContext.Request.Headers["Authorization"].FirstOrDefault();
            var userToken = token.Split(' ')[1];
            var user      = UserToken.FromToken(userToken);

            await _shoppingGroupService.SetActiveShoppingGroup(user.UserId, shoppingGroupRequest);

            return(Ok(HelperBox.DataToResponse <string>(true, "winkel groep is nu active")));
        }
Esempio n. 8
0
        public async Task <ActionResult <Response <ShoppingGroup> > > GetActiveShoppingGroup()
        {
            var token         = HttpContext.Request.Headers["Authorization"].FirstOrDefault();
            var userToken     = token.Split(' ')[1];
            var user          = UserToken.FromToken(userToken);
            var shoppingGroup = await _shoppingGroupService.GetActiveShoppingGroupByUserId(user.UserId);

            if (shoppingGroup == null)
            {
                return(BadRequest(HelperBox.DataToResponse <ShoppingGroup>(false, null, "Winkelgroep niet gevonden")));
            }
            return(Ok(HelperBox.DataToResponse(true, shoppingGroup)));
        }
        public async Task <ActionResult <Response <HomeAutomation.Models.Database.MyCalender.MyCalender> > > CreateNewCalender([FromBody] MyCalenderRequest newCalender)
        {
            var token     = HttpContext.Request.Headers["Authorization"].FirstOrDefault();
            var userToken = token.Split(' ')[1];
            var user      = UserToken.FromToken(userToken);

            var calender = await _calenderService.CreateNewCalender(newCalender, user.UserId);

            if (calender == null)
            {
                return(BadRequest(HelperBox.DataToResponse <object>(false, null, "Naam en Filenaam zijn verplicht")));
            }
            return(Ok(HelperBox.DataToResponse(true, calender)));
        }
Esempio n. 10
0
        public async Task <ActionResult <Response <ShoppingGroup> > > AddShoppingGroup([FromBody] ShoppingGroupRequest shoppingGroupRequest)
        {
            var token     = HttpContext.Request.Headers["Authorization"].FirstOrDefault();
            var userToken = token.Split(' ')[1];
            var user      = UserToken.FromToken(userToken);

            var newShoppingGroup = await _shoppingGroupService.CreateShoppingGroup(user.UserId, shoppingGroupRequest);

            if (newShoppingGroup == null)
            {
                return(BadRequest(HelperBox.DataToResponse <ShoppingGroup>(false, null, "Er is geen naam gegeven aan deze winkelgroep")));
            }
            return(Ok(HelperBox.DataToResponse(true, newShoppingGroup)));
        }
Esempio n. 11
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
            })));
        }
Esempio n. 12
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")));
        }
Esempio n. 13
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")));
        }
 public async Task <ActionResult <Response <ResponseList <HomeAutomation.Models.Database.MyCalender.MyCalender> > > > GetCalender()
 {
     return(Ok(HelperBox.DataToReponseList(true, await _calenderService.GetCalenders())));
 }
Esempio n. 15
0
        public async Task <ActionResult <Response <ResponseList <string> > > > GetAutoComplete([FromBody] AutoComplete autoComplete)
        {
            var options = await _productService.AutoComplete(autoComplete.text);

            return(Ok(HelperBox.DataToReponseList(true, options)));
        }