public async Task <ApiResult <bool> > Prosess(ProsessRequest request) { var notification = await _context.Notifications.FindAsync(request.Id); if (notification == null || notification.Status == false) { return(new ApiErrorResult <bool>("Không tìm thấy ")); } var equipment = await _context.Equipment.FindAsync(notification.Id_BLE); if (equipment.Status == true) { return(new ApiErrorResult <bool>("Thiết bị không khả dụng ")); } if (request.Status == "agree") { _context.Equipment.Remove(equipment); } else if (request.Status == "cancle") { equipment.Status = true; } else { return(new ApiErrorResult <bool>("Lỗi xử lý ")); } notification.Status = false; notification.DateUpdate = DateTime.UtcNow.AddHours(7); await _context.SaveChangesAsync(); return(new ApiSuccessResult <bool>("Cập nhật thành công")); }
public async Task <IActionResult> Update(ProsessRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _notificationService.Prosess(request); if (result.IsSuccessed == false) { return(BadRequest(result)); } return(Ok(result)); }