Пример #1
0
 public override void Execute()
 {
     var menuDefinition = ExecuteCommand(new GetMenuDefinitionCommand(MenuDefinitionId));
     var employeeMenus = ExecuteCommand(new GetEmployeeMenusCommand() { MenuDefinitionId = menuDefinition.Id });
     var order = new MenuOrder(menuDefinition, Now(), employeeMenus);
     order.IsOrdered = true;
     RavenSession.Store(order);
     menuDefinition.LastOrderDate = Now();
 }
Пример #2
0
        public static EmployeeMenuDTO Create(Employee employee, Menu menuDefinition, EmployeeMenu employeeMenu, MenuOrder lastOrder)
        {
            employeeMenu.EmployeeName = string.Format("{0}, {1}", employee.LastName, employee.FirstName);

            var result = new EmployeeMenuDTO
            {
                EmployeeMenu = employeeMenu,
                MenuDefinition = menuDefinition
            };

            if (lastOrder != null && lastOrder.DetailByUserName.ContainsKey(employee.UserName))
            {
                var detail = lastOrder.DetailByUserName[employee.UserName];
                result.LastOrder = new EmployeeMenuOrderDTO()
                {
                    Date = menuDefinition.LastOrderDate,
                    Option = detail.OptionKey == null ? null : lastOrder.OptionsByKey[detail.OptionKey],
                    Place = detail.PlaceKey == null ? null : lastOrder.PlacesByKey[detail.PlaceKey],
                    Comment = detail.Comment,
                    Food = detail.OptionKey == null ? null : lastOrder.FoodsByOption[detail.OptionKey],
                    WeekIdx = lastOrder.WeekIdx,
                    DayIdx = lastOrder.DayIdx,
                    IsOrdered = true
                };
            }
            else if (lastOrder != null)
            {
                result.LastOrder = new EmployeeMenuOrderDTO()
                {
                    Date = menuDefinition.LastOrderDate,
                    Option = null,
                    Place = null,
                    Comment = "// El usuario no existía al momento de hacer el pedido //",
                    Food = null,
                    WeekIdx = lastOrder.WeekIdx,
                    DayIdx = lastOrder.DayIdx,
                    IsOrdered = true
                };
            }

            return result;
        }