Beispiel #1
0
 public ActionResult Edit(TaiKhoan taiKhoan)
 {
     if (ModelState.IsValid)
     {
         taiKhoan.SaveFor(q => q.Avatar);
         if (taiKhoan.IDTaiKhoan > 0)
         {
             db.Entry(taiKhoan).State = EntityState.Modified;
         }
         else
         {
             db.TaiKhoans.Add(taiKhoan);
         }
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(taiKhoan));
 }
        public ActionResult Edit(TaiKhoan obj)
        {
            if (ModelState.IsValid)
            {
                obj.SaveFor(q => q.Avatar);

                if (obj.IDTaiKhoan > 0)
                {
                    db.Entry(obj).State = EntityState.Modified;
                }
                else
                {
                    obj.Active = 1;
                    obj.Rate   = 0;
                    obj.SoHD   = 0;
                    db.TaiKhoans.Add(obj);
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(obj));
        }