Пример #1
0
    public static void Main()
    {
        Chef chef = new Chef();

        Potato potato = new Potato();
        potato.IsRotten = false;

        if (potato != null)
        {
            // Potato will be peeled during Cook process, so this check is not necessary
            if (!potato.IsRotten)
            {
                chef.Cook(potato);
                Console.WriteLine("Potato is cooked!");
            }
            else
            {
                throw new ArgumentOutOfRangeException("Cannot cook rotten potato!");
            }
        }
        else
        {
            throw new ArgumentNullException("There is no potato!");
        }
    }
Пример #2
0
    /// <summary>
    /// The entry point of the application.
    /// </summary>
    private static void Main()
    {
        Chef theDev = new Chef();
        theDev.MakeSoup();

        Console.WriteLine(theDev.Log);
    }
    public static void Main(string[] args)
    {
        // First Task:
        Potato potato = new Potato();

        // ...
        if (potato == null)
        {
            throw new ArgumentNullException();
        }

        var me = new Chef("Ivan");
        var ingredients = new List<Vegetable>();
        ingredients.Add(potato);
        if (potato.IsPeeled && !potato.IsRotten)
        {
            me.CookVegitables(ingredients, new Bowl());
        }

        // Second Task:
        const int MIN_X = -100;
        const int MAX_X = 100;
        const int MIN_Y = -50;
        const int MAX_Y = 50;
        int x = 0;
        int y = 0;
        bool shouldVisitCell = true;
        bool inRangeX = MIN_X <= x && x <= MAX_X;
        bool inRangeY = MIN_Y <= y && y <= MAX_Y;

        if (inRangeX && inRangeY && shouldVisitCell)
        {
            VisitCell(x, y);
        }
    }
 public static void Main()
 {
     Chef chef = new Chef();
     Potato potato = new Potato();
     if (potato == null)
     {
         throw new ArgumentNullException("Potato should be created.");
     }
     else if (potato.IsPeeled && potato.IsRotten)
     {
             chef.Cook(potato);
     }
 }
 public IActionResult AddChefToDB(Chef chefToAdd)
 {
     // If validation errors, send back to form
     if (ModelState.IsValid == false)
     {
         return(View("AddChef"));
     }
     chefToAdd.CreatedAt = DateTime.Now;
     chefToAdd.UpdatedAt = DateTime.Now;
     db.Add(chefToAdd);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Пример #6
0
 public IActionResult CreateChef(Chef newChef)
 {
     if (ModelState.IsValid)
     {
         _context.Add(newChef);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("New"));
     }
 }
Пример #7
0
        public static Bowl ProcessVegetable(Vegetable vegetable, Chef chef)
        {
            bool isCookable = IsCookable(vegetable);

            if (isCookable)
            {
                return(chef.Cook(vegetable));
            }
            else
            {
                throw new ArgumentException("The vegetable must be peeled and not rotten in order to be cooked.");
            }
        }
Пример #8
0
 public IActionResult Create(Chef newChef)
 {
     if (ModelState.IsValid == false)
     {
         return(View("New"));                     //Just "New" - already in Chef
     }
     // ModalState.IsValid...
     // newDish.CreatedAt = DateTime.Now;        //works, but moved to Model's instantiation
     db.Chefs.Add(newChef);                      //DB Insert
     db.SaveChanges();
     return(RedirectToAction("Index"));
     // return RedirectToAction("Details", newDish.DishId);  //"Details", new {id = newDish.DishId}
 }
    /// <summary>
    ///
    /// </summary>
    private void ResearchTreeSaveSate(Save_State save)
    {
        for (int i = 0; i < Chef_Requirment_Purchasable.Count; i++)
        {
            Chef chef = Chef_Requirment_Purchasable[i];
            Chef_Research_Save_State save_state = new Chef_Research_Save_State();

            save_state.Name          = chef.Name;
            save_state.Unlocked      = chef.Unlocked;
            save_state.Current_Level = chef.CurrentLevel;
            save.Chef_Research_Save_State.Add(save_state);
        }
    }
Пример #10
0
 public static Chef_data FromDomain(Chef chef)
 {
     return(new Chef_data
     {
         firstname = chef.Firstname,
         lastname = chef.Lastname,
         age = chef.Age,
         email = chef.Email,
         mobile = chef.Mobile,
         residentialaddress = chef.Residentialaddress,
         idnumber = chef.Idnumber,
     });
 }
 public IActionResult AddChef(Chef newChef)
 {
     if (ModelState.IsValid)
     {
         dbContext.Chefs.Add(newChef);
         dbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("NewChef"));
     }
 }
 public IActionResult ChefCreator(Chef yourSurvey)
 {
     if (ModelState.IsValid)
     {
         dbContext.Add(yourSurvey);
         dbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("New"));
     }
 }
Пример #13
0
        public IActionResult AddNewChef(Chef newChef)
        {
            var ageCheck = DateTime.Now.Year - newChef.Birthday.Year;

            if (ageCheck < 18)
            {
                ModelState.AddModelError("Birthday", "Must be at least 18 years old");
                return(View("NewChef"));
            }
            dbContext.Add(newChef);
            dbContext.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #14
0
 public IActionResult AddChef(Chef chef)
 {
     if (ModelState.IsValid)
     {
         dbContext.Add(chef);
         dbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("ChefAddForm"));
     }
 }
Пример #15
0
 public IActionResult New(Chef thisChef)
 {
     if (ModelState.IsValid)
     {
         dbContext.Add(thisChef);
         dbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("New", thisChef));
     }
 }
Пример #16
0
 public IActionResult AddChef(Chef newChef)
 {
     if (ModelState.IsValid)
     {
         dbContext.AddChef(newChef);
     }
     else
     {
         return(View("NewChef"));
     }
     // return RedirectToAction("Index");
     return(Redirect("/"));
 }
Пример #17
0
        public IActionResult CreateDish(Dish newDish, int creatorId)
        {
            Chef creator = dbContext.Chefs.FirstOrDefault(chef => chef.ChefId == creatorId);

            newDish.Creator = creator;
            if (ModelState.IsValid)
            {
                dbContext.Add(newDish);
                dbContext.SaveChanges();
                return(RedirectToAction("DishesView"));
            }
            return(View("NewDish"));
        }
 public IActionResult CreateChef(Chef newchef)
 {
     if (ModelState.IsValid)
     {
         db.Add(newchef);
         db.SaveChanges();
         return(RedirectToAction("Index", newchef));
     }
     else
     {
         return(RedirectToAction("NewChef"));
     }
 }
        [Test] public void TestInsert()
        {
            Chef chef = new Chef();

            chef.FirstName = "Gil";
            chef.LastName  = "shinar";

            Db.Insert(chef);

            Chef chef2 = Db.Get <Chef>(chef.Id);

            Assert.AreEqual(chef, chef2);
        }
Пример #20
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var restaurante = new Restaurante();
            var chef1       = new Chef();

            restaurante.SacarPlato(chef1);
            restaurante.SacarPlato(chef1);
            var repostero1 = new Repostero();

            restaurante.SacarPlato(repostero1);

            MessageBox.Show($"El total es {restaurante.CostoTotal}");
        }
Пример #21
0
        public static void Main()
        {
            Potato potato = new Potato();

            if (potato != null)
            {
                if (!(potato.HasNotBeenPeeled || potato.IsRotten))
                {
                    Chef masterChef = new Chef();
                    masterChef.Cook(potato);
                }
            }
        }
Пример #22
0
 public IActionResult AddChefForm(Chef FromForm)
 {
     if (ModelState.IsValid)
     {
         dbContext.Chefs.Add(FromForm);
         dbContext.SaveChanges();
         return(RedirectToAction("DisplayChefs"));
     }
     else
     {
         return(View("AddChefPage", FromForm));
     }
 }
Пример #23
0
 public IActionResult CreateChef(Chef NewChef)
 {
     if (ModelState.IsValid)
     {
         dbContext.Add(NewChef);
         dbContext.SaveChanges();
         return(RedirectToAction("NewChef"));
     }
     else
     {
         return(View("NewChef"));
     }
 }
Пример #24
0
 public IActionResult ProcessChef(Chef newbie)
 {
     if (ModelState.IsValid)
     {
         dbContext.Chefs.Add(newbie);
         dbContext.SaveChanges();
         return(Redirect("/"));
     }
     else
     {
         return(View("AddChef"));
     }
 }
Пример #25
0
 public IActionResult processchef(Chef submitted_chef)
 {
     if (ModelState.IsValid)
     {
         dbContext.Add(submitted_chef);
         dbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("NewChef"));
     }
 }
Пример #26
0
 public IActionResult CreateChef(Chef FromForm)
 {
     if (ModelState.IsValid)
     {
         dbContext.Add(FromForm);
         dbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("addChef"));
     }
 }
Пример #27
0
 public IActionResult CreateChef(Chef newChef)
 {
     if (ModelState.IsValid)
     {
         _context.Chefs.Add(newChef);
         _context.SaveChanges();
         return(Redirect("/"));
     }
     else
     {
         return(View("AddChef"));
     }
 }
Пример #28
0
 private void new_user_button_Click(object sender, EventArgs e)
 {
     if (this.doublicate.Text != this.password_field.Text)
     {
         MessageBox.Show("Пароль введен с ошибкой");
         login_field.Text    = "";
         password_field.Text = "";
         doublicate.Text     = "";
     }
     else
     {
         string result = users.Check(login_field.Text, password_field.Text);
         if (result == "adm" || result == "che" || result == "Wrong_pas")
         {
             MessageBox.Show("Пользователь уже существует");
             login_field.Text    = "";
             password_field.Text = "";
             doublicate.Text     = "";
         }
         else
         {
             if (status.SelectedIndex == 1)
             {
                 Admin admin = new Admin(login_field.Text, password_field.Text);
                 users.Admins.Add(admin);
                 MessageBox.Show("Пользователь успешно добавлен");
                 users.Save();
                 this.Close();
                 Main_admin main_adm = new Main_admin();
                 main_adm.Show();
             }
             else
             {
                 if (status.SelectedIndex == 0)
                 {
                     Chef chef = new Chef(login_field.Text, password_field.Text);
                     users.Chefs.Add(chef);
                     MessageBox.Show("Пользователь успешно добавлен");
                     users.Save();
                     this.Close();
                     Main_admin main_adm = new Main_admin();
                     main_adm.Show();
                 }
                 else
                 {
                     MessageBox.Show("Выберите статус");
                 }
             }
         }
     }
 }
Пример #29
0
        // GET: Chefs/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Chef chef = db.Chefs.Find(id);

            if (chef == null)
            {
                return(HttpNotFound());
            }
            return(View(chef));
        }
Пример #30
0
        public IActionResult ChefUpdate(int ChefId, Chef dUpdated)
        {
            Chef chef = dbContext.Chefs.FirstOrDefault(d => d.ChefId == ChefId);

            chef.FirstName         = dUpdated.FirstName;
            chef.LastName          = dUpdated.LastName;
            chef.DOB               = dUpdated.DOB;
            chef.ChefRating        = dUpdated.ChefRating;
            chef.Description       = dUpdated.Description;
            chef.DataImageUrlField = dUpdated.DataImageUrlField;
            chef.UpdatedAt         = DateTime.Now;
            dbContext.SaveChanges();
            return(View("ChefShow", chef));
        }
Пример #31
0
        public IActionResult ChefForm(string cmd, int chefID)
        {
            Chef chef = new Chef();

            switch (cmd)
            {
            case "edit":
                chef = (Chef)dbContext.Chefs.FirstOrDefault(c => c.ChefID == chefID);
                return(View("ChefForm", chef));

            case "add":
            default: return(View("ChefForm", chef));
            }
        }
Пример #32
0
 public IActionResult ProcessNewChef(Chef newChef)
 {
     if (ModelState.IsValid)
     {
         System.Console.WriteLine($"{newChef.FirstName} | {newChef.LastName}***************************************");
         dbContext.Add(newChef);
         dbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("AddChefForm"));
     }
 }
Пример #33
0
        public string Disapprove(int Id, string Role)
        {
            if (string.Equals(Role, "DBoy", StringComparison.OrdinalIgnoreCase))
            {
                DeliveryBoy d = db.DeliveryBoy.Where(i => i.DeliveryBoyId == Id).FirstOrDefault();
                d.Approved = false;
                using (var tr = db.Database.BeginTransaction())
                {
                    try
                    {
                        db.DeliveryBoy.Update(d);
                        db.SaveChanges();

                        tr.Commit();

                        Utils.OrderEmail(d.Email, "Your account is locked by the KhanaGarKa.com team.");

                        return("OK");
                    }
                    catch
                    {
                        tr.Rollback();
                    }
                }
            }
            else if (string.Equals(Role, "Chef", StringComparison.OrdinalIgnoreCase))
            {
                Chef c = db.Chef.Where(i => i.ChefId == Id).FirstOrDefault();
                c.Approved = false;
                using (var tr = db.Database.BeginTransaction())
                {
                    try
                    {
                        db.Chef.Update(c);
                        db.SaveChanges();

                        tr.Commit();

                        Utils.OrderEmail(c.Email, "Your account is locked by the KhanaGarKa.com team.");

                        return("OK");
                    }
                    catch
                    {
                        tr.Rollback();
                    }
                }
            }
            return("");
        }
Пример #34
0
        public IActionResult Details(int id)
        {
            Chef selectedChef = _db.Chefs
                                .Include(c => c.Dishes)
                                .FirstOrDefault(c => c.ChefId == id);

            if (selectedChef == null)
            {
                RedirectToAction("All");
            }

            // ViewBag.uId = uId;
            return(View(selectedChef));
        }
Пример #35
0
        public ActionResult AssignOrderr(int id)
        {
            List <Chef> list = new List <Chef>();
            Chef        c    = new Chef();
            PassOrder   cat  = db.PassOrders.Find(id);

            if (cat != null)
            {
                ViewBag.msg = "This order has been assigned";
                return(RedirectToAction("ViewOrders", "Admin"));
            }
            TempData["id"] = id;
            return(RedirectToAction("Index1", "Admin"));
        }
        internal static void Main()
        {
            Potato goodPotato = new Potato();
            Potato badPotato = new Potato();
            Carrot carrot = new Carrot();
            Chef gRamsay = new Chef("G - Ramsay");

            gRamsay.PrepareVegetable(goodPotato);
            gRamsay.PrepareVegetable(carrot);

            Console.WriteLine("Test 1: (press any key for test 2)");
            CookMeal(gRamsay, goodPotato, carrot);

            Console.WriteLine("Test 2:");
            CookMeal(gRamsay, badPotato, carrot);
        }
Пример #37
0
        public static void PrepareMeal()
        {
            var potato = GetPotato();
            var chef = new Chef();

            if (potato == null)
            {
                throw new ArgumentNullException();
            }

            if((!potato.IsRotten)&&(potato.IsPeeled))
            {
                var bowl = chef.Cook();
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Пример #38
0
    private static void Main()
    {
        Chef gosho = new Chef("Georgi", "Oklahoma");

        Potato potato = new Potato(0.5, 0.3m);

        if (potato == null)
        {
            throw new ArgumentNullException("Vegetable item cannot be null");
        }

        if (!potato.IsPeeled && potato.IsRotten)
        {
            throw new ArgumentException(
                "Vegetable must be not rotten and peeled before cooking");
        }

        gosho.Cook(potato);
    }
 internal static void CookMeal(Chef chef, Potato potato, Carrot carrot)
 {
     if (potato != null && chef != null)
     {
         if (potato.IsPeeled && !potato.IsRotten)
         {
             chef.Cook(potato, carrot);
         }
         else
         {
             Console.WriteLine(chef.Name + " ANGRY!!! " + chef.Name + " SMASHHH!!!");
             Console.WriteLine("Don't you be givin me no rotten potatoes!");
             Console.ReadLine();
         }
     }
     else
     {
         Console.WriteLine("Where my potato AT!");
     }
 }
Пример #40
0
 static void Main()
 {
     Chef chef = new Chef();
     chef.Cook();
 }
Пример #41
0
 public static void Main(string[] args)
 {
     Chef chef = new Chef();
     chef.Cook();
 }
Пример #42
0
    public void EatFood(Chef sender, Food carryingFood)
    {
        MoveFoodToMouth(carryingFood,
            () =>
            {
                Eating = true;
                GameController.Instance.FoodEaten(sender, carryingFood, true);
            }
            );

        if (GameController.Instance.EatMirroredFoods)
        {
            ////also eat the food on the opposite side.
            //Chef mirrorChef = sender.GetMirrorChef();
            //if (mirrorChef.CarryingFood != null)
            //    mirrorChef.CarryingFood.Interact();
        }
    }
Пример #43
0
 public static void Main()
 {
     var chef = new Chef();
     var result = chef.Cook();
     result.Serve();
 }
Пример #44
0
    private static void Main()
    {
        Chef hristo = new Chef("Ico", "VelikoSelo");

        hristo.Cook();
    }
 public static void Main()
 {
     Chef chef = new Chef();
     chef.CookDish();
 }
Пример #46
0
 public static void Main()
 {
     var chef = new Chef();
     var bowl = chef.Cook();
     System.Console.WriteLine(bowl);
 }
Пример #47
0
 public static void Main()
 {
     var chef = new Chef();
     chef.Cook();
 }