Ejemplo n.º 1
0
        // GET: Customer/Edit/5
        public ActionResult Edit(int id)
        {
            Lib.Customer  libCustomer = Repo.GetCustomerById(id);
            CustomerModel webCustomer = new CustomerModel
            {
                Id          = libCustomer.ID,
                FirstName   = libCustomer.FirstName,
                LastName    = libCustomer.LastName,
                Address     = libCustomer.Address,
                PhoneNumber = libCustomer.PhoneNumber,
                StoreId     = libCustomer.StoreId
            };

            return(View(webCustomer));
        }
Ejemplo n.º 2
0
        // GET: Customer/Details/5
        public ActionResult Details(int id)
        {
            Lib.Customer  libCustomer = Repo.GetCustomerById(id);
            CustomerModel webCustomer = new CustomerModel
            {
                Id           = libCustomer.ID,
                StoreId      = libCustomer.StoreId,
                FirstName    = libCustomer.FirstName,
                LastName     = libCustomer.LastName,
                Address      = libCustomer.Address,
                PhoneNumber  = libCustomer.PhoneNumber,
                Store        = Repo.GetStoreById(libCustomer.StoreId),
                OrderBatches = Repo.GetOrderBatchesByCustomer(libCustomer.ID).OrderByDescending(o => o.Date)
            };

            return(View(webCustomer));
        }
Ejemplo n.º 3
0
 public ActionResult Edit(int id, CustomerModel customer)
 {
     try
     {
         // TODO: Add update logic here
         if (ModelState.IsValid)
         {
             Lib.Customer libCustomer = Repo.GetCustomerById(id);
             libCustomer.FirstName   = customer.FirstName;
             libCustomer.LastName    = customer.LastName;
             libCustomer.Address     = customer.Address;
             libCustomer.PhoneNumber = customer.PhoneNumber;
             libCustomer.StoreId     = customer.StoreId;
             Repo.UpdateCustomer(libCustomer);
             Repo.Save();
             return(RedirectToAction(nameof(Index)));
         }
         return(View(customer));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 4
0
 // GET: Customer/Delete/5
 public ActionResult Delete(int id)
 {
     Lib.Customer libCustomer = Repo.GetCustomerById(id);
     return(View(libCustomer));
 }