//METHODS public HoaViewModel() { hoa = new Hoa(); HoaRepository = new HoaRepository(); LoadHoa(); ModifyHoa = new Command(Modify, IsValid); DeleteHoa = new Command(Delete, IsValid); }
public ActionResult DeleteConfirmed(int id) { Hoa hoa = db.hoas.Find(id); db.hoas.Remove(hoa); db.SaveChanges(); return(RedirectToAction("Index")); }
public HoaViewModel() { hoa = new Hoa(); hoaRepository = new HoaRepository(); LoadHoa(); AddHoa = new Command(Insert); UpdateHoa = new Command(Update, CanEx); DeleteHoa = new Command(Delete, CanEx); }
private async void cmd_Xoa_Clicked(object sender, EventArgs e) { Hoa temp = new Hoa(); temp.TenHoa = TenHoa.Text; await App.Database.XoaHoa(temp); await Navigation.PopAsync(); }
public ThemHoaViewMode() { loaihoaRepository = new LoaihoaRepository(); hoaRepository = new HoaRepository(); loaihoas = loaihoaRepository.GetLoaihoas(); dshoa = hoaRepository.GetHoas(); loaihoa = new Loaihoa(); hoa = new Hoa(); AddHoa = new Command(InsertHoa); }
public ActionResult Edit([Bind(Include = "IdHoa,Ten,GiaBan,SoLuongCon,MoTa,Hinh")] Hoa hoa) { if (ModelState.IsValid) { db.Entry(hoa).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hoa)); }
public ActionResult Create([Bind(Include = "IdHoa,Ten,GiaBan,SoLuongCon,MoTa,Hinh")] Hoa hoa) { if (ModelState.IsValid) { db.hoas.Add(hoa); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hoa)); }
public Task <int> LuuHoa(Hoa temp) { if (temp.MaHoa != 0) { return(_database.UpdateAsync(temp)); } else { return(_database.InsertAsync(temp)); } }
public Task <int> SaveHoaAsync(Hoa hoa) { if (hoa.MaHoa != 0) { return(_database.UpdateAsync(hoa)); } else { return(_database.InsertAsync(hoa)); } }
public ActionResult XoaHoa(string idhoa) { Hoa h = data.Hoas.SingleOrDefault(n => n.MaHoa == idhoa); ViewBag.idhoa = h.MaHoa; if (h == null) { Response.StatusCode = 404; return(null); } return(View(h)); }
public ActionResult XacNhanXoa(string idh) { Hoa h = data.Hoas.SingleOrDefault(n => n.MaHoa == idh); ViewBag.idh = h.MaHoa; if (h == null) { Response.SubStatusCode = 404; return(null); } data.Hoas.DeleteOnSubmit(h); data.SubmitChanges(); return(RedirectToAction("QLH")); }
// GET: Admin/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Hoa hoa = db.hoas.Find(id); if (hoa == null) { return(HttpNotFound()); } return(View(hoa)); }
private async void cmd_Them_Clicked(object sender, EventArgs e) { Hoa temp = new Hoa(); temp.MaLoai = TypePicker.SelectedIndex; temp.TenHoa = TenHoa.Text; temp.Hinh = Hinh.Text; temp.DonGia = DonGia.Text; temp.MoTa = MoTa.Text; await App.Database.LuuHoa(temp); await Navigation.PopAsync(); }
public bool DeleteHoa(Hoa h) { try { using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "dlhoa.db"))) { connection.Delete(h); return(true); } } catch (SQLiteException ex) { return(false); } }
public bool InsertHoa(Hoa h) { try { using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "qlhoa.db"))) { connection.Insert(h); return(true); } } catch (SQLiteException ex) { // Log.Info("SQLiteEx", ex.Message); return(false); } }
public Task <int> XoaHoa(Hoa Hoa) { return(_database.Table <Hoa>().DeleteAsync(i => i.TenHoa == Hoa.TenHoa)); }
public ActionResult XemChiTiet(int id) { Hoa hoa = dbContext.hoas.Find(id);//database return(View("XemChiTiet", hoa)); }
public bool Insert(Hoa h) { // throw new NotImplementedException(); return(db.InsertHoa(h)); }
public bool Update(Hoa h) { return(db.UpdateHoa(h)); }
public bool Update(Hoa h) { // throw new NotImplementedException(); return(db.UpdateHoa(h)); }
public bool Delete(Hoa h) { return(db.DeleteHoa(h)); }
public bool Insert(Hoa h) { return(db.InsertHoa(h)); }
public int Delete(Hoa temp) { db.DeleteHoa(temp); return(0); }
public int Modify(Hoa temp) { db.SaveHoa(temp); return(0); }
public Task <int> DeleteHoaAsync(Hoa hoa) { return(_database.DeleteAsync(hoa)); }