public ActionResult Index() { //List<CustomersViewModel> cvml = new List<CustomersViewModel>(); //List<CustomersPartRecord> cpl = new List<CustomersPartRecord>(); CustomersViewModel cvm = new CustomersViewModel(); cvm.Name = "TEST NAME"; try { cvm.CVML = _customerRepo.Table.ToList(); } catch (Exception ex) { cvm.Name = ex.Message + Environment.NewLine + "//End Of Message//"; } if (cvm.CVML.Count() < 1) { CustomersPartRecord cvm2 = new CustomersPartRecord(); cvm2.Name = "Add 1st Customer"; cvm.CVML.Add(cvm2); } //cvm = cpl.CastClass<CustomersViewModel>(); // cvm.CVML = cpl; return(View(cvm)); }
public ActionResult Edit(int Id, string txtName, string txtAddress, string txtPhoneNumber , string txtPrimaryPOC, string txtPrimaryPOCEmail, string txtSecondaryPOC , string txtSecondaryPOCEmail, string txtEmailAlias, string txtNotes) { //get record of the ID to populate fields CustomersPartRecord cpr = new CustomersPartRecord(); cpr.Id = Id; cpr.Name = txtName; cpr.Address = txtAddress; cpr.PhoneNumber = txtPhoneNumber; cpr.PrimaryPOC = txtPrimaryPOC; cpr.PrimaryPOCEmail = txtPrimaryPOCEmail; cpr.SecondaryPOC = txtSecondaryPOC; cpr.SecondaryPOCEmail = txtSecondaryPOCEmail; cpr.EmailAlias = txtEmailAlias; cpr.Notes = txtNotes; try { _customerRepo.Update(cpr); } catch (NullReferenceException) { } return(RedirectToAction("Index")); }
public ActionResult Delete(CustomersPartRecord cpr, string btnSubmit) { if (btnSubmit.ToUpper() == "DELETE") { try { var record = _customerRepo.Get(r => r.Id == cpr.Id); _customerRepo.Delete(record); } catch (NullReferenceException) { } } return(RedirectToAction("Index")); }