예제 #1
0
 public ActionResult Create(ManufacturerAdd newItem)
 {
     if (ModelState.IsValid)
     {
         ManufacturerBase addedItem = m.AddManufacturer(newItem);
         // Should probably do a quick if-null test
         return(RedirectToAction("details", new { id = addedItem.Id }));
     }
     else
     {
         return(RedirectToAction("index"));
     }
 }
 public ActionResult Create(ManufacturerAdd newItem)
 {
     if (ModelState.IsValid)
     {
         ManufacturerBase addedItem = m.AddManufacturer(newItem);
         // Should probably do a quick if-null test
         return RedirectToAction("details", new { id = addedItem.Id });
     }
     else
     {
         return RedirectToAction("index");
     }
 }
예제 #3
0
        // ############################################################
        // Add new
        public ManufacturerBase AddManufacturer(ManufacturerAdd newItem)
        {
            // Create a design model object
            Manufacturer man = new Manufacturer();
            man.Name = newItem.Name;
            man.Country = newItem.Country;
            man.YearStarted = newItem.YearStarted;

            // Add and save
            ds.Manufacturers.Add(man);
            ds.SaveChanges();

            // Prepare the object to be returned
            ManufacturerBase addedItem = new ManufacturerBase();
            addedItem.Id = man.Id;
            addedItem.Name = man.Name;
            addedItem.Country = man.Country;
            addedItem.YearStarted = man.YearStarted;

            // Return the result
            return addedItem;
        }
예제 #4
0
        // ############################################################
        // Add new

        public ManufacturerBase AddManufacturer(ManufacturerAdd newItem)
        {
            // Create a design model object
            Manufacturer man = new Manufacturer();

            man.Name        = newItem.Name;
            man.Country     = newItem.Country;
            man.YearStarted = newItem.YearStarted;

            // Add and save
            ds.Manufacturers.Add(man);
            ds.SaveChanges();

            // Prepare the object to be returned
            ManufacturerBase addedItem = new ManufacturerBase();

            addedItem.Id          = man.Id;
            addedItem.Name        = man.Name;
            addedItem.Country     = man.Country;
            addedItem.YearStarted = man.YearStarted;

            // Return the result
            return(addedItem);
        }