Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
 public int Insert(Nguoidung entity)
 {
     db.Nguoidungs.Add(entity);
     db.SaveChanges();
     return(entity.ID_Nguoidung);
 }
Esempio n. 3
0
 public long Insert(about entity)
 {
     db.abouts.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
Esempio n. 4
0
 public long Insert(Tintuc entity)
 {
     db.Tintucs.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
Esempio n. 5
0
 public long Insert(Thucpham entity)
 {
     db.Thucphams.Add(entity);
     db.SaveChanges();
     return(entity.ID_thucpham);
 }
Esempio n. 6
0
 public long Insert(Footer entity)
 {
     db.Footers.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
Esempio n. 7
0
 public int Insert(Quanly entity)
 {
     db.Quanlies.Add(entity);
     db.SaveChanges();
     return(entity.ID_Quanly);
 }