Exemplo n.º 1
0
    public ActionResult Edit(long id)
    {
        CodeFirstDatabaseEntities db = new CodeFirstDatabaseEntities();
        Brand2 thisbrand             = db.Brands.Where(br => br.BrandID == id).FirstOrDefault();

        return(View(thisbrand));
    }
Exemplo n.º 2
0
    public ActionResult Delete(long id, Brand2 br)
    {
        CodeFirstDatabaseEntities db = new CodeFirstDatabaseEntities();
        Brand2 toDeleteBrand2        = db.Brands.Where(t2 => t2.BrandID == id).FirstOrDefault();

        db.Brands.Remove(toDeleteBrand2);
        db.SaveChanges();
        return(RedirectToAction("Index", "Brands"));
    }
Exemplo n.º 3
0
    public ActionResult Edit(Brand2 br)
    {
        CodeFirstDatabaseEntities db = new CodeFirstDatabaseEntities();

        if (ModelState.IsValid)
        {
            Brand2 thisBrand = db.Brands.Where(a => a.BrandID == br.BrandID).FirstOrDefault();
            thisBrand.BrandName = br.BrandName;
            db.SaveChanges();
            return(RedirectToAction("Index", "Brands"));
        }
        return(View(br));
    }
Exemplo n.º 4
0
    public ActionResult Create(Brand2 br)
    {
        CodeFirstDatabaseEntities db = new CodeFirstDatabaseEntities();

        if (ModelState.IsValid)
        {
            db.Brands.Add(br);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        else
        {
            return(View(br));
        }
    }