Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "ID,Prenom,Nom,DateNaissance,Address")] Personne personne)
        {
            if (ModelState.IsValid)
            {
                db.Personnes.Add(personne);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(personne));
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "CategoryId,Name,CategoryDescription")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include="ProductId,DateProd,Description,Name,Price,Quantity,CategoryId")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Name", product.CategoryId);
            return View(product);
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "Id,Name,Description,Price,Image,CategoryId")] Book book, HttpPostedFileBase upload, HttpPostedFileBase vid)
        {
            if (ModelState.IsValid)
            {
                String path  = Path.Combine(Server.MapPath("~/Uploads"), upload.FileName);
                String path2 = Path.Combine(Server.MapPath("~/Uploads"), vid.FileName);
                vid.SaveAs(path2);
                upload.SaveAs(path);
                //enregistrer path dans la BD
                book.Fichier = vid.FileName;
                book.Image   = upload.FileName;
                db.Books.Add(book);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Name", book.CategoryId);
            return(View(book));
        }
        private void Seed(MyFinanceContext context)
        {
            var jsonTestDataFileName = "TestData.json";
            var absolutePathForDocs  = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + jsonTestDataFileName);

            var json     = File.ReadAllText(absolutePathForDocs);
            var jObject  = JObject.Parse(json);
            var expenses = jObject["expenses"]?.ToObject <IEnumerable <Expense> >();

            foreach (var expense in expenses)
            {
                context.Expenses.Add(expense);
            }

            context.SaveChanges();

            foreach (var entity in context.ChangeTracker.Entries())
            {
                entity.State = EntityState.Detached;
            }
        }
Ejemplo n.º 6
0
 public void commit()
 {
     _ctx.SaveChanges();
 }
Ejemplo n.º 7
0
 public void commit()
 {
     context.SaveChanges();
 }
Ejemplo n.º 8
0
 public void AddProduct(Product prod)
 {
     ctx.Products.Add(prod);
     ctx.SaveChanges();
 }
Ejemplo n.º 9
0
 public void Commit()
 {
     dataContext.SaveChanges();
 }
Ejemplo n.º 10
0
 public void AddCategory(Category cat)
 {
     ctx.Categories.Add(cat);
     ctx.SaveChanges();
 }
Ejemplo n.º 11
0
 public void Commit()
 {
     ctx.SaveChanges();
 }
Ejemplo n.º 12
0
 public void AddProvider(Provider prov)
 {
     ctx.Providers.Add(prov);
     ctx.SaveChanges();
 }
Ejemplo n.º 13
0
 public void Add(User u)
 {
     ctx.Users.Add(u);
     ctx.SaveChanges();
 }
Ejemplo n.º 14
0
 public void TearDown()
 {
     _myFinanceDbContext.Expenses.RemoveRange(_myFinanceDbContext.Expenses);
     _myFinanceDbContext.SaveChanges();
 }
Ejemplo n.º 15
0
 public void Add(Book b)
 {
     ctx.Books.Add(b);
     ctx.SaveChanges();
 }