示例#1
0
 public ActionResult Edit(Employee employee)
 {
     db.Employees.Update(employee);
     // сохраняем в бд все изменения
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
示例#2
0
 public ActionResult Edit(Material material)
 {
     db.Materials.Update(material);
     // сохраняем в бд все изменения
     db.SaveChanges();
     return(RedirectToAction("index"));
 }
 public ActionResult Edit(Supply supply)
 {
     db.Supplies.Update(supply);
     // сохраняем в бд все изменения
     db.SaveChanges();
     return(RedirectToAction("index"));
 }
 public ActionResult Edit(Product product)
 {
     db.Products.Update(product);
     // сохраняем в бд все изменения
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
示例#5
0
 public ActionResult Edit(Order order)
 {
     db.Orders.Update(order);
     // сохраняем в бд все изменения
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public ActionResult Edit(ProductComposition productComposition)
 {
     db.ProductCompositions.Update(productComposition);
     // сохраняем в бд все изменения
     db.SaveChanges();
     return(RedirectToAction("index"));
 }
示例#7
0
        public static void Initialize(SewingStudioContext db)
        {
            db.Database.EnsureCreated();

            if (db.Materials.Any())
            {
                return;
            }

            int    materialsNumber          = 100;
            int    productsNumber           = 100;
            int    productCompositionNumber = 1000;
            int    supplyNumber             = 1000;
            int    employersNumber          = 300;
            int    ordersNumber             = 1000;
            string voc    = "QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm";
            Random random = new Random(1);

            for (int id = 1; id <= materialsNumber; id++)
            {
                db.Materials.Add(
                    new Material
                {
                    Name = GenRandomString(voc, 10),
                    Type = GenRandomString(voc, 10)
                });
            }

            db.SaveChanges();

            for (int id = 1; id <= productsNumber; id++)
            {
                db.Products.Add(
                    new Product
                {
                    Name  = GenRandomString(voc, 10),
                    Price = random.Next(10, 1000)
                });
            }

            db.SaveChanges();

            for (int id = 1; id <= productCompositionNumber; id++)
            {
                db.ProductCompositions.Add(
                    new ProductComposition
                {
                    MaterialId = random.Next(1, materialsNumber - 1),
                    ProductId  = random.Next(1, productsNumber - 1),
                    Quantity   = random.Next(10, 1000)
                });
            }
            db.SaveChanges();

            for (int id = 1; id <= supplyNumber; id++)
            {
                db.Supplies.Add(
                    new Supply
                {
                    MaterialId    = random.Next(1, materialsNumber - 1),
                    Price         = random.Next(10, 1000),
                    Quantity      = random.Next(10, 1000),
                    Supplier      = GenRandomString(voc, 10),
                    Delivery_date = DateTime.Now.Date.AddDays(-id)
                });
            }
            db.SaveChanges();

            for (int id = 1; id <= ordersNumber; id++)
            {
                db.Orders.Add(
                    new Order
                {
                    ProductId     = random.Next(1, productsNumber - 1),
                    Price         = random.Next(10, 1000),
                    Quantity      = random.Next(10, 1000),
                    Date_of_order = DateTime.Now.Date.AddDays(-id),
                    Date_of_sale  = DateTime.Now.Date.AddDays(30)
                });
            }
            db.SaveChanges();

            for (int id = 1; id <= employersNumber; id++)
            {
                db.Employees.Add(
                    new Employee
                {
                    Name                 = GenRandomString(voc, 10),
                    Surname              = GenRandomString(voc, 15),
                    Patronymic           = GenRandomString(voc, 15),
                    OrderId              = random.Next(1, ordersNumber - 1),
                    Date_of_delivery     = DateTime.Now.Date.AddDays(30),
                    Execution_start_date = DateTime.Now.Date.AddDays(-id)
                });
            }
            db.SaveChanges();
        }