internal static CODE_RESULT_RETURN Add(AppUser user)
 {
     using (var context = DBContext.GetContext())
     {
         var ds = (from e in context.AppUserDbSet
                   where e.UserName == user.UserName
                   select e).SingleOrDefault();
         if (ds != null)
             return CODE_RESULT_RETURN.MaTrung;
         else
         {
             context.AppUserDbSet.Add(user);
             context.SaveChanges();
             return CODE_RESULT_RETURN.ThanhCong;
         }
     }
 }
 internal static CODE_RESULT_RETURN Delete(AppUser user)
 {
     using (var context = DBContext.GetContext())
     {
         var nsd = (from e in context.AppUserDbSet
                    where e.UserName == user.UserName
                    select e).SingleOrDefault();
         if (nsd != null)
         {
             try
             {
                 context.AppUserDbSet.Remove(nsd);
                 context.SaveChanges();
                 return CODE_RESULT_RETURN.ThanhCong;
             }
             catch
             {
                 return CODE_RESULT_RETURN.ThatBai;
             }
         }
         return CODE_RESULT_RETURN.ThatBai;
     }
 }
 internal static void ChangePassword(AppUser m_NguoiSuDung, string matKhauMoi)
 {
     using (var db = DBContext.GetContext())
     {
         AppUser nguoiSuDung = db.AppUserDbSet.Where(
             nsd => nsd.UserName == m_NguoiSuDung.UserName &&
                 nsd.Password == m_NguoiSuDung.Password).FirstOrDefault();
         if (nguoiSuDung == null)
             throw new Exception("Thông tin người sử dụng không đúng!");
         else
         {
             try
             {
                 nguoiSuDung.Password = matKhauMoi;
                 db.SaveChanges();
             }
             catch
             {
                 throw new Exception("Không thể thay đổi mật khẩu được!");
             }
         }
     }
 }
 internal static CODE_RESULT_RETURN Update(AppUser user)
 {
     using (var db = DBContext.GetContext())
     {
         var ds = (from e in db.AppUserDbSet
                   where e.UserName == user.UserName
                   select e).SingleOrDefault();
         if (ds != null)
         {
             ds.FullName = user.FullName;
             ds.Password = user.Password;
             ds.Role = user.Role;
             ds.IsActive = user.IsActive;
             db.SaveChanges();
             return CODE_RESULT_RETURN.ThanhCong;
         }
         return CODE_RESULT_RETURN.ThatBai;
     }
 }