コード例 #1
0
        private async Task <ActionResult <bool> > EditStatusAsync(EditStatusDto editStatus)
        {
            var oldProcessingTypeId = (ProcessType)Enum.Parse(typeof(ProcessType), editStatus.OldProcessingType);

            await this.orderService.ChangeOrderStatusAsync(oldProcessingTypeId, (ProcessType)editStatus.NewProcessingTypeId, editStatus.OrderId);

            return(true);
        }
コード例 #2
0
        public async Task AcceptOrder(EditStatusDto editStatus)
        {
            var statusEditted = await this.EditStatusAsync(editStatus);

            if (!statusEditted.Value)
            {
                throw new InvalidOperationException("There was an error changing the status of the order!");
            }

            var user = await this.userManager.GetUserAsync(this.Context.User);

            await this.orderService.AddWaiterToOrderAsync(editStatus.OrderId, user.Id);

            var order = this.orderService.GetOrderInListById(editStatus.OrderId);

            var chefIds = (await this.userManager.GetUsersInRoleAsync(GlobalConstants.ChefRoleName)).Select(x => x.Id);

            await this.Clients.Users(chefIds).SendAsync("NewChefOrder", new
            {
                Date       = order.Date,
                Name       = order.FullName,
                StatusName = Enum.GetName(typeof(ProcessType), order.Status),
                Price      = order.Price,
                OrderId    = order.Id,
            });

            var waiterId       = this.orderService.GetWaiterId(editStatus.OrderId);
            var orderViewModel = this.orderService.GetActiveOrderById(order.Id);

            await this.Clients.User(waiterId).SendAsync(
                "NewActiveTable",
                new
            {
                TableNumber  = orderViewModel.TableNumber,
                ProcessType  = Enum.GetName(typeof(ProcessType), orderViewModel.ProcessType),
                IsPaid       = orderViewModel.IsPaid,
                Id           = orderViewModel.Id,
                ReadyPercent = orderViewModel.ReadyPercent,
            });

            var waiterIds = this.userManager.GetUsersInRoleAsync(GlobalConstants.WaiterRoleName).Result.Select(x => x.Id);

            await this.Clients.Users(waiterIds).SendAsync(
                "RemoveNewWaiterOrder",
                new
            {
                OrderId = order.Id,
            });
        }
コード例 #3
0
        public async Task <ActionResult <bool> > AcceptOrder(EditStatusDto editStatus)
        {
            var statusEditted = await this.EditStatusAsync(editStatus);

            if (!statusEditted.Value)
            {
                throw new InvalidOperationException("There was an error changing the status of the order!");
            }

            var userId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            await this.orderService.AddWaiterToOrderAsync(editStatus.OrderId, userId);

            return(true);
        }