예제 #1
0
        public int Commit()
        {
            int returned = 0;

            try
            {
                returned = Context.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(0);
            }
            return(returned);
        }
예제 #2
0
        public static void Listener()
        {
            while (true)
            {
                var itemChoise = Misc.ItemChoise();
                ShowDB(itemChoise);
                var actionChoice = Misc.ActionChoice(itemChoise);
                int id;
                switch (actionChoice)
                {
                case 1:
                    id = Misc.GetId(itemChoise, db);
                    RemoveItembyId(itemChoise, id);
                    break;

                case 2:
                    AddDefault(itemChoise);
                    break;

                case 3:
                    AddItem(itemChoise);
                    break;

                case 4:
                    id = Misc.GetId(itemChoise, db);
                    ShowItemById(itemChoise, id);
                    break;

                case 5:
                    id = Misc.GetId(itemChoise, db);
                    UpdateItemById(itemChoise, id);
                    break;
                }
                db.SaveChanges();
                Misc.ConsoleLog(ConsoleColor.Yellow, "Changes have been saved, exit (Y/N)?");
                string temp = Console.ReadLine();
                if (temp == "Y" || temp == "y")
                {
                    break;
                }
            }
        }
예제 #3
0
 public async Task <IActionResult> AddItem([Bind("name,description,material,price,imageSrc")] Clothes cloth)
 {
     db.Cloth.Add(cloth);
     db.SaveChanges();
     return(RedirectToAction(nameof(ClothManager)));
 }