コード例 #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"));
     }
 }
コード例 #2
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");
     }
 }
コード例 #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);
        }