public async Task <IActionResult> AssignRecordToDriver(RecordAssignInput input) { Record record = await _db.Records.FirstOrDefaultAsync(x => x.RecordGuid == input.RecordId); record.DriverId = input.DriverId; long userId = _db.Drivers.FirstOrDefault(y => y.Id == input.DriverId).UserId; _db.Entry(record).State = EntityState.Modified; var result = await _db.SaveChangesAsync(); if (result == 1) { PushNotificationInput pushNotificationInput = new PushNotificationInput { UserId = userId, title = "كشف جديد", body = "تم تعيين كشف جديد لك", }; await _pushNotificationService.PushNotification(pushNotificationInput); return(new OkObjectResult(1)); } throw new Exception("حصل خطأ"); }
public async Task <IActionResult> AssignRecordToDriver([FromBody] RecordAssignInput model) { try { await _driverService.AssignRecordToDriver(model); return(Ok("تمت العملية بنجاح")); } catch (Exception e) { return(BadRequest("حصل خطأ يرجى المحاولة مرة اخرى")); } }