Example #1
0
        public async Task <THAMSO> getThamSo(string tenThamSo)
        {
            try
            {
                THAMSO thamSo = await _connectionToDatabaseAsync.Table <THAMSO>().Where(ts =>
                                                                                        (ts.TenThamSo == tenThamSo)).FirstOrDefaultAsync();

                return(thamSo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        public async Task <bool> updateThamSo(string tenThamSo, int giaTri)
        {
            try
            {
                THAMSO currentThamSo = await _connectionToDatabaseAsync.Table <THAMSO>().Where(ts =>
                                                                                               (ts.TenThamSo == tenThamSo)).FirstOrDefaultAsync();

                if (currentThamSo == null)
                {
                    throw new Exception("Không tìm thấy tham số có tên '" + tenThamSo + "'.");
                }
                currentThamSo.GiaTri = giaTri;
                await _connectionToDatabaseAsync.UpdateAsync(currentThamSo);

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #3
0
 public async Task<bool> updateThamSo(THAMSO thamSo)
 {
     try
     {
         THAMSO currentThamSo = await _connectionToDatabaseAsync.Table<THAMSO>().Where(ts =>
         (ts.TenThamSo.Trim() == thamSo.TenThamSo.Trim())).FirstOrDefaultAsync();
         if (currentThamSo == null)
             throw new Exception("Không tìm thấy tham số có tên '" + thamSo.TenThamSo + "'.");
         currentThamSo.GiaTri = thamSo.GiaTri;
         currentThamSo.MoTa = thamSo.MoTa;
         await _connectionToDatabaseAsync.UpdateAsync(currentThamSo);
         return true;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }