예제 #1
0
 public ActionResult Create(Category c, HttpPostedFileBase upload)
 {
     if (ModelState.IsValid)
     {
         c.Picture = MyHelper.UploadFile(upload, 3);
         myService.Add(c);
         myService.Commit();
         return(RedirectToAction("Index"));
     }
     return(View(c));
 }
예제 #2
0
파일: Program.cs 프로젝트: chix12/MyFinance
        static void Main(string[] args)
        {
            MyfinanctCtx     ctx = new MyfinanctCtx();
            IServiceProduct  sp  = new ServiceProduct();
            IServiceCategory sc  = new ServiceCategory();

            Category c = new Category {
                Name = "vetements"
            };

            ctx.Categories.Add(c);
            Product p1 = new Product()
            {
                Name        = "Prod1",
                Description = "description",
                Price       = 2200,
                Quantity    = 5,
                DateProd    = DateTime.Now,
                Category    = c
            };

            Product p2 = new Product()
            {
                Name        = "Produit 2",
                Description = "description du produit 2",
                Price       = 100,
                Quantity    = 10,
                DateProd    = DateTime.Now,
                Category    = c
            };


            sp.Add(p1);
            sp.Add(p2);
            sc.Add(c);
            // sc.Commit();
            sp.Commit();
            // ctx.Products.Add(p1);
            // ctx.SaveChanges();//ne perend pas cpt au niveau de la base de données
            Console.WriteLine("base crée");
            Console.ReadKey();
        }
예제 #3
0
 public DtoActionResult Post(EntityCategory category)
 {
     return(_categoryService.Add(category));
 }