Exemple #1
0
        public static EmployeeMenuDTO Create(Employee employee, Menu menuDefinition, EmployeeMenu employeeMenu, MenuOrder todayOrder, bool hasTomorrowBeenOrdered = false)
        {
            employeeMenu.EmployeeName = string.Format("{0}, {1}", employee.LastName, employee.FirstName);

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

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

            return(result);
        }
        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;
        }