public BranchesView GetBranchView(int id) { BranchesView branch = new BranchesView(); branch = GetBranchesViews().Where(o => o.BranchID.Equals(id)).FirstOrDefault(); return(branch); }
public void AddBranch(BranchesView BV) { using (CMSProjectEntities db = new CMSProjectEntities()) { BranchList branch = new BranchList(); branch.StreetAddress = BV.StreetAddress; branch.City = BV.City; branch.State = BV.State; branch.Pincode = BV.Pincode; branch.Active = true; db.BranchLists.Add(branch); db.SaveChanges(); } }
public void UpdateBranch(BranchesView BV) { using (CMSProjectEntities db = new CMSProjectEntities()) { BranchList branch = new BranchList(); branch.BranchID = BV.BranchID; branch.StreetAddress = BV.StreetAddress; branch.City = BV.City; branch.State = BV.State; branch.Pincode = BV.Pincode; branch.Active = (bool)BV.Active; db.Entry(branch).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public ActionResult AddOrEditB(BranchesView BV) { DataManager DM = new DataManager(); if (BV.BranchID == 0) { DM.AddBranch(BV); return(Json(new { success = true, message = "Added Successfully!" }, JsonRequestBehavior.AllowGet)); } else { DM.UpdateBranch(BV); return(Json(new { success = true, message = "Updated Successfully!" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult DeleteB(int id) { DataManager DM = new DataManager(); BranchesView BV = new BranchesView(); BV = DM.GetBranchView(id); using (CMSProjectEntities db = new CMSProjectEntities()) { BranchList branch = new BranchList(); branch.BranchID = BV.BranchID; branch.StreetAddress = BV.StreetAddress; branch.City = BV.City; branch.State = BV.State; branch.Pincode = BV.Pincode; branch.Active = (bool)BV.Active; db.Entry(branch).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet)); } }
public List <BranchesView> GetBranchesViews() { List <BranchesView> BV = new List <BranchesView>(); using (CMSProjectEntities db = new CMSProjectEntities()) { var branchlist = db.BranchLists.ToList(); foreach (BranchList BL in branchlist) { BranchesView branchesView = new BranchesView(); branchesView.BranchID = BL.BranchID; branchesView.StreetAddress = BL.StreetAddress; branchesView.City = BL.City; branchesView.State = BL.State; branchesView.Pincode = BL.Pincode; branchesView.Active = BL.Active; BV.Add(branchesView); } } return(BV); }
private void BranchButton_Click(object sender, RoutedEventArgs e) { DataContext = new BranchesView(); }