예제 #1
0
파일: Manager.cs 프로젝트: spurani/Projects
        // ProductAdd()
        public CustomerBase CustomerAdd(CustomerAdd newItem)
        {
            var addedItem = ds.Customers.Add(mapper.Map <CustomerAdd, Customer>(newItem));

            ds.SaveChanges();

            return((addedItem == null) ? null : mapper.Map <Customer, CustomerBase>(addedItem));
        }
예제 #2
0
        public CustomerBase CustomerAdd(CustomerAdd newItem)
        {
            // Attempt to add the new item
            // Notice how we map the incoming data to the design model object
            var addedItem = ds.Customers.Add(Mapper.Map<Customer>(newItem));
            ds.SaveChanges();

            // If successful, return the added item, mapped to a view model object
            return (addedItem == null) ? null : Mapper.Map<CustomerBase>(addedItem);
        }
예제 #3
0
        public CustomerBase CustomerAdd(CustomerAdd newItem)
        {
            // Attempt to add the new item
            // Notice how we map the incoming data to the design model object
            var addedItem = ds.Customers.Add(mapper.Map <Customer>(newItem));

            ds.SaveChanges();

            // If successful, return the added item, mapped to a view model object
            return((addedItem == null) ? null : mapper.Map <CustomerBase>(addedItem));
        }
예제 #4
0
        public ActionResult Create(CustomerAdd newItem)
        {
            if (!ModelState.IsValid)
            {
                return(View(newItem));
            }

            var addedItem = m.CustomerAdd(newItem);

            if (addedItem == null)
            {
                return(View(newItem));
            }
            else
            {
                return(RedirectToAction("details", new { id = addedItem.CustomerId }));
            }
        }
        public ActionResult Create(CustomerAdd newItem)
        {
            // Validate the input
            if (!ModelState.IsValid)
            {
                return View(newItem);
            }

            // Process the input
            var addedItem = m.CustomerAdd(newItem);

            if (addedItem == null)
            {
                return View(newItem);
            }
            else
            {
                return RedirectToAction("details", new { id = addedItem.CustomerId });
            }
        }