protected void btnAddPlan_Click(object sender, EventArgs e) { var plan = new Plan { PlanName = txtPlanName.Text, PlanFixedCost = Decimal.Parse(txtPlanFixedCost.Text), PlanVarCost = Decimal.Parse(txtPlanVarCost.Text) }; var repo = new PlanRepo(); try { int returnVal = repo.Add(plan); panelDisplayPlans.Visible = true; gridViewPlans.Visible = true; //Wizard1.Visible = false; //lblPlanInstructions.Visible = false; panelAddPlan.Visible = false; lblShowPlans.Text = "Plan successfully added. Here is the updated list:"; } catch (Exception ex) { throw ex; } }
// The return type can be changed to IEnumerable, however to support // paging and sorting, the following parameters must be added: // int maximumRows // int startRowIndex // out int totalRowCount // string sortByExpression public IEnumerable <CustomersAndPlans> GridViewCustomersAndPlans_GetData() { List <CustomersAndPlans> customerPlans = new List <CustomersAndPlans>(); var customers = new CustomerRepo().GetAll(); foreach (var c in customers) { var planInfo = new PlanRepo().GetOne(c.PlanID); customerPlans.Add(new CustomersAndPlans { CustID = c.CustID, CustName = c.CustName, CustEmail = c.CustEmail, PlanName = planInfo.PlanName, PlanFixedCost = planInfo.PlanFixedCost, PlanVarCost = planInfo.PlanVarCost }); } return(customerPlans); }
protected void btnAddCustomer_Click(object sender, EventArgs e) { var selectedPlan = new PlanRepo().GetAll().Where(x => x.PlanName == cboPlan.SelectedValue).FirstOrDefault(); //var plan = new PlanRepo().ExecuteQuery($"select planID from plan where planname = {cboPlan.SelectedValue};"); var customer = new Customer { CustName = txtCustomerName.Text, CustEmail = txtCustomerEmail.Text, PlanID = selectedPlan.PlanID }; var repo = new CustomerRepo(); int returnVal = repo.Add(customer); panelDisplayCustomers.Visible = true; gridViewCustomers.Visible = true; panelAddCustomer.Visible = false; lblShowCustomers.Text = "Customer successfully added. Here is the updated list:"; }
public PlanController(PlanRepo planRepo) { _PlanRepo = planRepo; }