public async Task <IActionResult> GetPaging([FromQuery] MatchBindingModel collection) { if (string.IsNullOrWhiteSpace(collection?.Token)) { return(BadRequest(GeneralMessage.TokenNotFound)); } if (string.IsNullOrWhiteSpace(collection?.DeviceId)) { return(BadRequest(GeneralMessage.DeviceIdNotFound)); } try { var model = _mapper.Map <PredictionGetPagingSchema>(collection); var result = await _predictionService.GetPagingAsync(model); switch (model.StatusCode) { case 1: return(Ok(data: _mapper.Map <IEnumerable <PredictionViewModel> >(result), totalPages: collection.TotalPages(model.RowsCount))); case -1: return(BadRequest(GeneralMessage.UserNotFound)); case -2: return(BadRequest(GeneralMessage.UserIsNotActive)); case -3: return(BadRequest(GeneralMessage.PhoneIsNotVerified)); } } catch (Exception ex) { await _exceptionService.InsertAsync(ex, URL, IP); } return(InternalServerError()); }
public async Task <IActionResult> Get([FromQuery] HeaderBindingModel collection) { try { var model = _mapper.Map <UserGetSchema>(collection); var user = await _userService.GetAsync(model); switch (model.StatusCode) { case 1: user.Avatar = string.IsNullOrWhiteSpace(user.Avatar) ? null : $"{AppSettings.FileUrl}/avatars/{user.Avatar}"; return(Ok(data: _mapper.Map <UserViewModel>(user))); case -1: return(BadRequest(GeneralMessage.UserNotFound)); case -2: return(BadRequest(GeneralMessage.UserIsNotActive)); case -3: return(BadRequest(GeneralMessage.PhoneIsNotVerified)); } } catch (Exception ex) { await _exceptionService.InsertAsync(ex, URL, IP); } return(InternalServerError()); }
public async Task <int> InsertAsync(HttpLog model, int timeoutMS) { var startTime = DateTime.UtcNow; try { using (var timeoutCancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMilliseconds(timeoutMS))) { await _mongoDBContext.HttpLogs.InsertOneAsync(model, cancellationToken : timeoutCancellationTokenSource.Token); } return(1); } catch (OperationCanceledException ex) { await _exceptionService.InsertAsync(ex, "Domain.Application.ServicesHttpLogService.Insert", ""); var elapsed = DateTime.UtcNow - startTime; return(0); } }