コード例 #1
0
        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("حصل خطأ");
        }
コード例 #2
0
        public async Task <IActionResult> AssignRecordToDriver([FromBody] RecordAssignInput model)
        {
            try
            {
                await _driverService.AssignRecordToDriver(model);

                return(Ok("تمت العملية بنجاح"));
            }
            catch (Exception e)
            {
                return(BadRequest("حصل خطأ يرجى المحاولة مرة اخرى"));
            }
        }