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); }
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()); }