public ActionResult <Customer> GetById(int id) { if (id == 0) { return(null); } var customer = _customerModel.GetCustomerById(id); return(Ok(customer)); }
public void TestGetCustomerById() { var customer = new Customer("Adam", "Hansen", "Test"); var customerId = customer.Id; _customerModel.AddCustomer(customer); var customerFromModel = _customerModel.GetCustomerById(customerId); Assert.IsTrue(customer.Id == customerFromModel.Id); }
/// <summary> /// Give user option to edit a customer /// </summary> private static void DisplayEditCustomer() { ListAllCustomers(); Console.WriteLine(); if (CustomerModel.GetCustomers().Any()) { Console.WriteLine("Please write id of customer to edit:"); var customerIdInput = MenuManager.GetSelectedCustomerId(CustomerModel.GetCustomers()); var selectedCustomer = CustomerModel.GetCustomerById(customerIdInput); CustomerManager.EditCustomer(selectedCustomer); Console.WriteLine("New customer info:"); selectedCustomer.DisplayInfo(); } }
// GET: CustomerMaster/Edit/5 public ActionResult Edit(int id) { var moveToList = new List<SelectListItem>(); MoveToModel moveModel = new MoveToModel(); moveModel.MoveTo = "AMC Customer"; moveToList.Add(new SelectListItem { Text = moveModel.MoveTo, Value = moveModel.MoveTo }); moveModel = new MoveToModel(); moveModel.MoveTo = "Warranty List"; moveToList.Add(new SelectListItem { Text = moveModel.MoveTo, Value = moveModel.MoveTo }); moveModel = new MoveToModel(); moveModel.MoveTo = "MAC Inprocess"; moveToList.Add(new SelectListItem { Text = moveModel.MoveTo, Value = moveModel.MoveTo }); moveModel = new MoveToModel(); moveModel.MoveTo = "Inactive Customer"; moveToList.Add(new SelectListItem { Text = moveModel.MoveTo, Value = moveModel.MoveTo }); ViewBag.MoveToList = moveToList; CustomerModel cm = new CustomerModel(); cm = cm.GetCustomerById(id); cm.listMoveTo = moveToList; return View(cm); }
// GET: CustomerMaster/Details/5 public ActionResult Details(int id) { CustomerModel cm = new CustomerModel(); cm = cm.GetCustomerById(id); return View(cm); }
public ActionResult Details(int id) { return(View(customerModel.GetCustomerById(id))); }