public bool Thembua(string username, string sobua, DateTime date, decimal pro, decimal fat, decimal carbs)//ajax json { var sob = Int32.Parse(sobua); var id = GetById(username).ID_Nguoidung; var totalcalo = pro * 4 + carbs * 4 + fat * 9; Theodoibuaan entity = new Theodoibuaan(); entity.ID_Nguoidung = id; entity.ID_sobuatrongngay = Int32.Parse(sobua); entity.Ngaythang = date; entity.Fat_ba = fat; entity.Protein_ba = pro; entity.Carb_ba = carbs; entity.Total_calos = totalcalo; int check = GetByiddate(sob, date, id); if (check != 0) { var buaaner = db.Theodoibuaans.Find(check); buaaner.ID_Nguoidung = id; buaaner.ID_sobuatrongngay = Int32.Parse(sobua); buaaner.Ngaythang = date; buaaner.Fat_ba = fat; buaaner.Protein_ba = pro; buaaner.Carb_ba = carbs; buaaner.Total_calos = totalcalo; db.SaveChanges(); return(true); } else { try { db.Theodoibuaans.Add(entity); db.SaveChanges(); return(true); } catch (Exception ex) { return(false); } } }
public int Insert(Nguoidung entity) { db.Nguoidungs.Add(entity); db.SaveChanges(); return(entity.ID_Nguoidung); }
public long Insert(about entity) { db.abouts.Add(entity); db.SaveChanges(); return(entity.ID); }
public long Insert(Tintuc entity) { db.Tintucs.Add(entity); db.SaveChanges(); return(entity.ID); }
public long Insert(Thucpham entity) { db.Thucphams.Add(entity); db.SaveChanges(); return(entity.ID_thucpham); }
public long Insert(Footer entity) { db.Footers.Add(entity); db.SaveChanges(); return(entity.ID); }
public int Insert(Quanly entity) { db.Quanlies.Add(entity); db.SaveChanges(); return(entity.ID_Quanly); }