public async Task <IHttpActionResult> Delete(string id) { var result = new TransferObj <bool>(); CUAHANG instance = await _service.Repository.FindAsync(id); if (instance == null) { return(NotFound()); } try { _service.Delete(instance.ID); int del = await _service.UnitOfWork.SaveAsync(); if (del > 0) { result.Data = true; result.Status = true; result.Message = "Xóa thành công bản ghi"; } else { result.Data = false; result.Status = false; result.Message = "Thao tác không thành công"; } } catch (Exception e) { result.Data = false; result.Status = false; result.Message = e.Message; } return(Ok(result)); }
public List <BuildQuery.IQueryFilter> GetFilters() { var result = new List <IQueryFilter>(); var refObj = new CUAHANG(); if (!string.IsNullOrEmpty(this.MA_CUAHANG)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.MA_CUAHANG), Value = this.MA_CUAHANG, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.TEN_CUAHANG)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.TEN_CUAHANG), Value = this.TEN_CUAHANG, Method = FilterMethod.Like }); } return(result); }
public ActionResult Add(CUAHANG model) { var ChiNhanh = db.CUAHANGs.Find(model.MaCuaHang); db.CUAHANGs.Add(model); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(CUAHANG model) { var obj = db.CUAHANGs.Find(model.MaCuaHang); obj.MaCuaHang = model.MaCuaHang; obj.Ten = model.Ten; obj.SDT = model.SDT; obj.TrangThai = model.TrangThai; obj.MaXa = model.MaXa; db.SaveChanges(); return(RedirectToAction("index", model)); }
public static int sua(CUAHANG ch) { try { DAO.QLDOITAC.sua(ch); return(1); } catch (Exception ex) { Console.WriteLine(ex.Message); return(0); } }
public static void sua(CUAHANG ch) { db.Entry(ch).State = EntityState.Modified; db.SaveChanges(); }
public static void them(CUAHANG ch) { db.CUAHANGs.Add(ch); db.SaveChanges(); }