public bool fUpdateCenter(mCenter pCenter) { tbl_center a = new tbl_center(); a.center_id = pCenter.center_id; a.center_cat = pCenter.center_cat; a.center_city = pCenter.center_city; a.center_img = pCenter.center_img; a.center_info = pCenter.center_info; a.center_title = pCenter.center_title; Db.tbl_center.Attach(a); Db.Entry(a).State = System.Data.Entity.EntityState.Modified; return(Convert.ToBoolean(Db.SaveChanges())); }
public bool InsertCenter(mCenter pCenter) { try { tbl_center vCenter = new tbl_center(); var query = from b in Db.tbl_center orderby b.center_id descending select b; vCenter = query.FirstOrDefault(); tbl_center a = new tbl_center(); a.center_cat = pCenter.center_cat; a.center_city = pCenter.center_city; a.center_img = pCenter.center_img; a.center_info = pCenter.center_info; a.center_title = pCenter.center_title; a.center_id = vCenter.center_id + 1; Db.tbl_center.Add(a); return(Convert.ToBoolean(Db.SaveChanges())); } catch (Exception) { return(false); } }