public BranchEditVM(BRANCH b, BranchVM vm) { if (b == null) { this.Branch_id = ""; this.Address = ""; this.Name = ""; this.City = ""; this.State = ""; this.Zip_code = ""; this.cv = "insert"; } else { this.Branch_id = b.BRANCH_ID.ToString(); this.Address = b.ADDRESS; this.Name = b.NAME; this.City = b.CITY; this.State = b.STATE; this.Zip_code = b.ZIP_CODE; this.cv = "update"; } this.vm = vm; OKCommand = new RelayCommand <Window>((p) => { return(p != null ? true : false); }, (p) => { OKevent(p); }); CancelCommand = new RelayCommand <Window>((p) => true, (p) => { p.Close(); }); }
public ActionResult Delete(int ID) { BRANCH aBranch = bmse.BRANCHes.Find(ID); bmse.BRANCHes.Remove(aBranch); bmse.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(BRANCH aBranch, HttpPostedFileBase ManagerPicture) { aBranch.BRANCH_MANAGER_PICTURE = Path.GetFileName(ManagerPicture.FileName); aBranch.BRANCH_MANAGER_JOINDATE = DateTime.Now; if (ModelState.IsValid) { bmse.Entry(aBranch).State = EntityState.Modified; bmse.SaveChanges(); ManagerPicture.SaveAs(Server.MapPath("../../Uploads/Manager_Picture/" + aBranch.BRANCH_ID.ToString() + "_" + aBranch.BRANCH_MANAGER_PICTURE)); return(RedirectToAction("Index")); } return(View(aBranch)); }
public ActionResult Create(BRANCH aBranch, HttpPostedFileBase BRANCH_MANAGER_PICTURE) { aBranch.BRANCH_MANAGER_PICTURE = Path.GetFileName(BRANCH_MANAGER_PICTURE.FileName); aBranch.BRANCH_MANAGER_JOINDATE = DateTime.Now; if (ModelState.IsValid) { bmse.BRANCHes.Add(aBranch); bmse.SaveChanges(); BRANCH_MANAGER_PICTURE.SaveAs(Server.MapPath("../Uploads/Manager_Picture/" + aBranch.BRANCH_ID.ToString() + "_" + aBranch.BRANCH_MANAGER_PICTURE)); return(RedirectToAction("Index")); } return(View(aBranch)); }
public ActionResult Delete(int?ID) { if (ID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BRANCH aBranch = bmse.BRANCHes.Find(ID); if (aBranch == null) { return(HttpNotFound()); } return(View(aBranch)); }
private void OKevent(Window p) { BRANCH bra = new BRANCH(); bra.BRANCH_ID = int.Parse(Branch_id); bra.CITY = City; bra.ADDRESS = Address; bra.STATE = State; bra.NAME = Name; bra.ZIP_CODE = Zip_code; if (cv == "insert") { BranchDao.Instance().Insert(bra); vm.BranchLists = new ObservableCollection <BRANCH>(BranchDao.Instance().getAll()); } else { BranchDao.Instance().Update(bra); vm.BranchLists = new ObservableCollection <BRANCH>(BranchDao.Instance().getAll()); } p.Close(); }