Exemple #1
0
        public async Task <ServiceRespone> PostMuaVip(MuaVip muaVip)
        {
            ServiceRespone res = new ServiceRespone();

            muaVip.NgayMua = DateTime.Now;
            _context.MuaVips.Add(muaVip);
            res.Success = true;
            res.Message = "Đã Đăng Ký Gói!";
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (MuaVipExists(muaVip.TaiKhoan))
                {
                    res.Message = "Tài khoản nạp thêm hạn";
                }
                else
                {
                    res.Message = "Có lỗi!";
                    res.Success = false;
                    throw;
                }
            }

            return(res);
        }
Exemple #2
0
        public async Task <IActionResult> PutMuaVip(string id, MuaVip muaVip)
        {
            if (id != muaVip.TaiKhoan)
            {
                return(BadRequest());
            }

            _context.Entry(muaVip).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MuaVipExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }