コード例 #1
0
ファイル: OrderService.cs プロジェクト: thunder913/TechToranT
        public ChefViewModel GetChefViewModel()
        {
            var viewModel = new ChefViewModel();

            viewModel.NewOrders = this.GetOrdersWithStatus(ProcessType.InProcess);
            viewModel.FoodTypes = this.GetCookFoodTypes();
            return(viewModel);
        }
コード例 #2
0
        public ActionResult Edit(int id = 0)
        {
            ChefViewModel model = new ChefViewModel();

            if (id != 0)
            {
                model = new ChefViewModel(repo.GetByID(id));
            }

            return(View(model));
        }
コード例 #3
0
        public ActionResult Edit(ChefViewModel model)
        {
            Chef chef = repo.GetByID(model.ID);

            if (model.ID == 0)
            {
                chef = new Chef();
            }

            chef.Name = model.Name;

            repo.Save(chef);
            return(RedirectToAction("Index"));
        }
コード例 #4
0
 private void FormChef_Load(object sender, EventArgs e)
 {
     if (id.HasValue)
     {
         try
         {
             ChefViewModel view = service.GetElement(id.Value);
             if (view != null)
             {
                 textBoxFIO.Text = view.ChefFIO;
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
コード例 #5
0
        public ActionResult KitchenInformation()
        {
            var applicationDbContext = _context.Buffets.Include(b => b.Guest);

            ChefViewModel model = new ChefViewModel();


            foreach (var buffet in applicationDbContext)
            {
                model.Date       = buffet.Date;
                model.GuestCount = buffet.Guest.Count;
                foreach (var guest in buffet.Guest)
                {
                    if (guest.Type == "Adult")
                    {
                        model.AdultCount++;
                    }
                    if (guest.Type == "Kid")
                    {
                        model.KidCount++;
                    }
                    if (guest.Type == "Adult" && guest.BuffetCheckIn == true)
                    {
                        model.AdultCheckInCount++;
                    }
                    if (guest.Type == "Kid" && guest.BuffetCheckIn == true)
                    {
                        model.KidCheckInCount++;
                    }

                    if (guest.BuffetCheckIn == true)
                    {
                        model.CheckInCount++;
                    }
                    else if (guest.BuffetCheckIn == false)
                    {
                        model.NotCheckInCount++;
                    }
                }
            }

            return(View(model));
        }
コード例 #6
0
        public IActionResult Create(ChefViewModel chef)
        {
            if (!ModelState.IsValid)
            {
                return(View("NewChef"));
            }

            int now = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
            int dob = int.Parse(chef.DateOfBirth.ToString("yyyyMMdd"));
            int age = (now - dob) / 10000;

            if (dob > now)
            {
                ModelState.AddModelError("DateOfBirth", "Date of birth must be in the past!");
                return(View("NewChef"));
            }

            if (age < 18)
            {
                ModelState.AddModelError("DateOfBirth", "Chef must be 18 years of age!");
                return(View("NewChef"));
            }

            System.Console.WriteLine("#####################################");
            System.Console.WriteLine(age);

            Chef newChef = new Chef
            {
                FirstName = chef.FirstName,
                LastName  = chef.LastName,
                Age       = age,
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now
            };

            _context.Add(newChef);
            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }
コード例 #7
0
        public ActionResult View(int id)
        {
            ChefViewModel model = new ChefViewModel(repo.GetByID(id));

            return(View(model));
        }
コード例 #8
0
        // GET: Chef
        public ActionResult Index()
        {
            ChefViewModel model = new ChefViewModel(repo.GetAll());

            return(View(model));
        }