// ############################################################
        // Add new
        public ManufacturerBase AddManufacturer(ManufacturerAdd newItem)
        {
            // Create a design model object

            Manufacturer man = Mapper.Map<Manufacturer>(newItem);

            /*
            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 and return the object
            return Mapper.Map<ManufacturerBase>(man);

            /*
            // 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;
            */
        }
Exemple #2
0
        // ############################################################
        // Add new

        public ManufacturerBase AddManufacturer(ManufacturerAdd newItem)
        {
            // Create a design model object

            Manufacturer man = Mapper.Map <Manufacturer>(newItem);

            /*
             * 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 and return the object
            return(Mapper.Map <ManufacturerBase>(man));

            /*
             * // 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;
             */
        }
 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"));
     }
 }