public ActionResult AddCustomer(Customer customer) { if (ModelState.IsValid) { customerRepository.Add(customer); return RedirectToAction("Customer", "Home"); } return View(); }
public ActionResult Customer() { try { Customer model = new Customer(); model.ListofCustomers = customerRepository.Get(); model.Cards = GetCards(); return View(model); } catch (Exception ex) { logger.Error("Error while getting a customer details. Error Details are: " + ex.Message); return RedirectToAction("Index", "Error"); } }
public ActionResult AddCustomer(Customer customer) { try { if (ModelState.IsValid) { customerRepository.Add(customer); return new JavaScriptResult { Script = "alert('Customer added sucessfully');" }; } } catch (Exception ex) { logger.Error("Error while adding a customer. Error Details are: " + ex.Message); return new JavaScriptResult { Script = "alert('Error while adding customer');" }; } return View(); }
public void Add(Customer customer) { try { CustomerData cd = new CustomerData(); cd.FirstName = customer.FirstName; cd.LastName = customer.LastName; cd.MobileNumber = customer.MobileNumber; cd.Email = customer.Email; cd.Address = customer.Address; cd.cardId = customer.CardId; client.AddCustomer(cd); } catch (Exception ex) { throw ex; } }
public ActionResult Customer() { ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application."; Customer model = new Customer(); model.ListofCustomers = customerRepository.Get(); model.Cards = GetCards(); return View(model); }