public async Task <IActionResult> GetCategoryByService(CategoryFilterRequest filter) { int userId = 0; var userstr = this.User.FindFirstValue(ClaimTypes.Name); if (!string.IsNullOrWhiteSpace(userstr)) { userId = Convert.ToInt32(userstr); } var ownResponse = new ListResponse <CategoryResponseViewModel>(); var dataResult = await _unit.ICategory.GetCategoryByServiceId(filter); if (dataResult.HasSuccess) { ownResponse.Message = "Success"; ownResponse.Status = true; ownResponse.Data = dataResult.UserObject; return(ownResponse.ToHttpResponse()); } else { ownResponse.Message = "Service is not availabe for selected address."; ownResponse.Status = false; ownResponse.Data = null; return(ownResponse.ToHttpResponse()); } }
public async Task <IActionResult> GetDropSlot([FromQuery] SlotsRequestViewModel model) { var ownResponse = new ListResponse <TimeSlotViewModel>(); string fullDate; try { var sDate = model.FullDate.Split(' '); fullDate = Common.DateTimeConverter.DatetimeConverterfromString(sDate[0], format: DateTimeConverter.DateFormat.YYMMDD); fullDate = fullDate + " " + sDate[1]; var dd = Convert.ToDateTime(fullDate); } catch (Exception ex) { throw; } var dataResult = await _unit.IOrder.GetAvailableDropSlots(Convert.ToDateTime(fullDate)); if (dataResult.HasSuccess) { ownResponse.Message = "Success"; ownResponse.Status = true; ownResponse.Data = dataResult.UserObject; return(ownResponse.ToHttpResponse()); } else { ownResponse.Message = "No data found"; ownResponse.Status = true; ownResponse.Data = dataResult.UserObject; return(ownResponse.ToHttpResponse()); } }
public async Task <IActionResult> Post([FromForm] UserAddressRequestViewModel value) { int?userId = 0; var struserId = this.User.FindFirstValue(ClaimTypes.Name); if (!string.IsNullOrWhiteSpace(struserId)) { userId = Convert.ToInt32(struserId); } var response = new ListResponse <UserAddressResponseViewModel>(); try { var result = new ApiResult <bool>(); if (value.AddressId != null && value.AddressId > 0) { result = await _unit.IUserAddress.UpdateUserAddress(userAddress : value, userId : userId.Value); response.Data = (await _unit.IUserAddress.UserAddress(userId: userId.Value, addressId: value.AddressId)).UserObject; response.Message = "Success"; response.Status = true; return(response.ToHttpResponse()); } else { result = await _unit.IUserAddress.SaveUserAddress(userAddress : value, userId : userId.Value); if (result.HasSuccess) { response.Data = null; response.Message = "Success"; response.Status = true; } else { response.Data = null; response.Message = "Error"; response.Status = false; } } } catch (Exception ex) { response.Status = false; response.Message = "There was an internal error, please contact to technical support."; ErrorTrace.Logger(LogArea.ApplicationTier, ex); } return(response.ToHttpResponse()); }
public async Task <IActionResult> GetProductSubcategories(Int32?pageSize = 10, Int32?pageNumber = 1) { var response = new ListResponse <ProductSubcategoryViewModel>(); try { // Get query var query = ProductionRepository.GetProductSubcategories(); // Set information for paging response.PageSize = (Int32)pageSize; response.PageNumber = (Int32)pageNumber; response.ItemsCount = await query.CountAsync(); // Retrieve items var list = await query .Paging((Int32)pageSize, (Int32)pageNumber) .ToListAsync(); // Set model for response response.Model = list.Select(item => item.ToViewModel()); response.Message = String.Format("Total of records: {0}", response.Model.Count()); } catch (Exception ex) { response.DidError = true; response.ErrorMessage = ex.Message; } return(response.ToHttpResponse()); }
public IActionResult ObterTodosProdutos() { var response = new ListResponse <ProdutoDTO>(); try { var produtos = _produtoService.ObterTodosProdutos(); if (produtos.Count() > 0) { response.Data = MapearProdutos(produtos); response.Success = true; } else { response.Success = false; response.Message = "A lista de produtos não foi encontrada!"; } } catch (Exception ex) { response.Success = false; response.Message = $"Erro interno não identificado. Detalhes: {ex.Message}"; } return(response.ToHttpResponse()); }
public async Task <IActionResult> GetStockItemsAsync(string name) { Logger?.LogDebug("'{0}' has been invoked", nameof(GetStockItemsAsync)); var response = new ListResponse <Project>(); try { var projects = await _projectService.GetProjectsByName(name); if (projects.Count() == 0) { response.Message = "No items in stock"; } else { IEnumerable <Project> resource = _mapper.Map <IEnumerable <Project> >(projects); response.Model = resource; } Logger?.LogInformation("The stock items have been retrieved successfully."); } catch (Exception ex) { response.DidError = true; response.ErrorMessage = "There was an internal error, please contact to technical support."; Logger?.LogCritical("There was an error on '{0}' invocation: {1}", nameof(GetStockItemsAsync), ex); } return(response.ToHttpResponse()); }
public async Task <IActionResult> GetOrders(Int32?pageSize = 10, Int32?pageNumber = 1, String salesOrderNumber = "", String customerName = "") { var response = new ListResponse <OrderSummaryViewModel>(); try { // Get query var query = SalesRepository.GetOrders(salesOrderNumber, customerName); // Set information for paging response.PageSize = (int)pageSize; response.PageNumber = (int)pageNumber; response.ItemsCount = await query.CountAsync(); // Retrieve items var list = await query.Paging((int)pageSize, (int)pageNumber).ToListAsync(); // Set model for response response.Model = list.Select(item => item.ToViewModel()); response.Message = String.Format("Total of records: {0}", response.Model.Count()); } catch (Exception ex) { response.DidError = true; response.ErrorMessage = ex.Message; } return(response.ToHttpResponse()); }
public async Task <IActionResult> GetAllAsync() { logger?.LogDebug("'{0}' has been invoked", nameof(GetAllAsync)); var response = new ListResponse <ProductResource>(); try { var products = await productService.ListAsync(); response.Model = mapper.Map <IEnumerable <Product>, IEnumerable <ProductResource> >(products); response.Message = string.Format("Total of products: {0}.", response.Model.Count()); logger?.LogInformation("The products have been retrieved successfully."); } catch (Exception ex) { response.DidError = true; response.ErrorMessage = "There was an internal error, please contact to technical support."; logger?.LogCritical("There was an error on '{0}' invocation: {1}", nameof(GetAllAsync), ex); } return(response.ToHttpResponse()); }
public async Task <IActionResult> GetServiceByStore([FromQuery] int storeId) { int customerId = 0; string userId = User.FindFirstValue(ClaimTypes.Name); if (!string.IsNullOrWhiteSpace(userId)) { customerId = Convert.ToInt32(userId); } var response = new ListResponse <ServiceMasterResponseViewModel>(); var data = await _unit.IService.GetServiceByStore(storeId); if (data.HasSuccess) { response.Data = data.UserObject; response.Status = true; } else { response.Data = null; response.Status = false; } return(response.ToHttpResponse()); }
public async Task <IActionResult> GetSlot() { var ownResponse = new ListResponse <TimeSlotViewModel>(); var dataResult = await _unit.IOrder.GetAvailableSlots(); if (dataResult.HasSuccess) { ownResponse.Message = "Success"; ownResponse.Status = true; ownResponse.Data = dataResult.UserObject; return(ownResponse.ToHttpResponse()); } else { ownResponse.Message = "No data found"; ownResponse.Status = true; ownResponse.Data = dataResult.UserObject; return(ownResponse.ToHttpResponse()); } }
public async Task <IActionResult> GetOrderDetail([FromQuery] int orderType) { int? userId = 0; string strStatus = string.Empty; var userStrId = this.User.FindFirstValue(ClaimTypes.Name); if (!string.IsNullOrWhiteSpace(userStrId)) { userId = Convert.ToInt32(userStrId); } if (orderType == (int)EnumType.OrderTypeEnum.UPCOMING) { strStatus = "5,6,7,8,9,11,12,13,14,15"; } if (orderType == (int)EnumType.OrderTypeEnum.HISTORY) { strStatus = ",10,16"; } var ownResponse = new ListResponse <OrderDetailResponseViewModel>(); var dataResult = await _unit.IOrder.GetOrderByDeliveryBoyId(userId.Value, strStatus); if (dataResult.HasSuccess) { ownResponse.Message = "Success"; ownResponse.Status = true; ownResponse.Data = dataResult.UserObject; return(ownResponse.ToHttpResponse()); } else { ownResponse.Message = "No data found"; ownResponse.Status = true; ownResponse.Data = dataResult.UserObject; return(ownResponse.ToHttpResponse()); } }
[ProducesResponseType(500)] //If there was an internal server error public async Task <IActionResult> GetUsersAsync() { var response = new ListResponse <UserBindingModel>(); List <UserBindingModel> userBindingModel = new List <UserBindingModel>(); List <User> users = await this._userManagementService.GetUsersAsync(isLocked : false, isActive : true); response.Model = this._mapper.Map <List <UserBindingModel> >(users); return(response.ToHttpResponse()); }
public async Task <IActionResult> GetTransactionsBySku(string Sku) { Logger?.LogDebug("'{0}' has been invoked", nameof(GetTransactionsBySku)); var response = new ListResponse <Transaction>(); var outputCurrency = "EUR"; try { var dataRates = (await GetAllRates()).ToList(); _dbContext = new MyDbContext(); var dataTransactions = (await GetAllTransactions()).ToList(); var filteredTransactions = dataTransactions.Where(t => t.Sku.Equals(Sku)).ToList(); foreach (var transaction in filteredTransactions) { List <Rate> listFinalRates = new List <Rate>(); if (transaction.Currency.Equals(outputCurrency)) { continue; } Converter.SearchBestRate(transaction.Currency, outputCurrency, listFinalRates, dataRates); for (int i = 0; i < listFinalRates.Count(); i++) { if (transaction.Currency.Equals(outputCurrency)) { break; } var rate = listFinalRates.FirstOrDefault(r => r.From.Equals(transaction.Currency)); transaction.Currency = rate.To; transaction.Amount = transaction.Amount * rate.RateValue; } } response.Model = filteredTransactions; response.Message = $"Total of Transactions: {filteredTransactions.Count()} , Sum of all Amount: {filteredTransactions.Sum(t => t.Amount)} {outputCurrency}"; } catch (Exception ex) { ResponseError(response, ex, nameof(GetTransactionsBySku)); } return(response.ToHttpResponse()); }
public async Task <IActionResult> GetAllProducts() { var response = new ListResponse <ProductResponseModel>(); try { response.Data = await _productService.GetAllAsync(); } catch (Exception ex) { response.Meta.Code = -1; response.Meta.ErrorMessage = "Internal server error."; _logger.Error("There was an error on 'GetAllProducts' invocation.", ex); } return(response.ToHttpResponse()); }
public async Task <IActionResult> Handle(GetKycDocumentQueryByyfranchiseeId request, CancellationToken cancellationToken) { var _response = new ListResponse <KycDocumetResposneModel>(); var result = await _account.GetKycDocumetsByFranchiseeId(request.FranchiseeId); if (result.HasSuccess) { _response.Data = result.UserObject; _response.Status = true; } else { _response.Message = result.ResultCode.MessageText; _response.Status = true; } return(_response.ToHttpResponse()); }
public async Task <IActionResult> Handle(GetAllAdminEmployeeQuery request, CancellationToken cancellationToken) { var _response = new ListResponse <GetAllAdminEmployeeQuery>(); var result = await _company.GetAllAdminEmployee(); if (result.HasSuccess) { _response.Data = result.UserObject; _response.Status = true; } else { _response.Message = result.ResultCode.MessageText; _response.Status = true; } return(_response.ToHttpResponse()); }
public async Task <IActionResult> Get() { int userId = 0; var userStrId = this.User.FindFirstValue(ClaimTypes.Name); if (!string.IsNullOrWhiteSpace(userStrId)) { userId = Convert.ToInt32(userStrId); } var ownResponse = new ListResponse <UserAddressResponseViewModel>(); ownResponse.Data = (await _unit.IUserAddress.UserAddress(userId: userId)).UserObject; ownResponse.Message = "Success"; ownResponse.Status = true; return(ownResponse.ToHttpResponse()); }
public async Task <IActionResult> Handle(GetTestsForEndUser request, CancellationToken cancellationToken) { var _response = new ListResponse <TestListQueryModel>(); var result = await _testForEnd.GetTestListync(request); if (result.HasSuccess) { _response.Data = result.UserObject; _response.Status = true; } else { _response.Message = result.ResultCode.MessageText; _response.Status = true; } return(_response.ToHttpResponse()); }
public async Task <IActionResult> Handle(GetQuestionFilterQuery request, CancellationToken cancellationToken) { var _response = new ListResponse <QuestionWithListQuery>(); var result = await _question.GetQuestionDetailAsync(request); if (result.HasSuccess) { _response.Data = result.UserObject; _response.Status = true; } else { _response.Message = result.ResultCode.MessageText; _response.Status = true; } return(_response.ToHttpResponse()); }
public async Task <IActionResult> Handle(GetAllTraingDocumnentsQuery request, CancellationToken cancellationToken) { var _response = new ListResponse <TraingDocumnentsResponseModel>(); var result = await _usertraing.GetAllTrainingDocuments(); if (result.HasSuccess) { _response.Data = result.UserObject; _response.Status = true; } else { _response.Message = result.ResultCode.MessageText; _response.Status = true; } return(_response.ToHttpResponse()); }
public async Task <IActionResult> Handle(GetAllTestUserQuery request, CancellationToken cancellationToken) { var _response = new ListResponse <UserTestMappingResponseModel>(); var result = await _test.GetAllTestUser(request); if (result.HasSuccess) { _response.Data = result.UserObject; _response.Status = true; } else { _response.Message = result.ResultCode.MessageText; _response.Status = true; } return(_response.ToHttpResponse()); }
public async Task <HttpResponseMessage> GetAssetsHeader() { var response = new ListResponse <RMD_Asset_Header>(); try { response.Model = await AssetService.GetRmd_Asset_Header(); } catch (Exception e) { response.DidError = true; response.ErrorMessage = "There was an internal error, please contact to technical support.".ToUpper(); _logger?.Error($"There was an error on '{nameof(GetAssetsCategory)}' invocation: {e}".ToUpper()); } return(response.ToHttpResponse()); }
public async Task <IActionResult> GetImportedDatabasesAsync() { Logger?.LogDebug("'{0}' has been invoked", nameof(GetImportedDatabasesAsync)); var response = new ListResponse <ImportedDatabase>(); try { response.Model = await DbService.GetImportedDatabasesAsync(); } catch (Exception ex) { response.SetError(ex, Logger); } return(response.ToHttpResponse()); }
public async Task <IActionResult> Handle(GetAllComapanyUserQuery request, CancellationToken cancellationToken) { var _response = new ListResponse <SupervisorResponseQueryModel>(); var result = await _account.GetAllSupervisorForAdmin(request); if (result.HasSuccess) { _response.Data = result.UserObject; _response.Status = true; } else { _response.Message = result.ResultCode.MessageText; _response.Status = true; } return(_response.ToHttpResponse()); }
public async Task <IActionResult> Handle(GetAllDistrictByStateIdQuery request, CancellationToken cancellationToken) { var _response = new ListResponse <DistrictQueryMode>(); var result = await _common.GetAllDistrictByStateId(request.StateId); if (result.HasSuccess) { _response.Data = result.UserObject; _response.Status = true; } else { _response.Message = result.ResultCode.MessageText; _response.Status = true; } return(_response.ToHttpResponse()); }
public async Task <IActionResult> Handle(GetAllDocumentTypeQuery request, CancellationToken cancellationToken) { var _response = new ListResponse <DocumentTypeQueryModel>(); var result = await _account.GetAllDocumentTypeAsync(); if (result.HasSuccess) { _response.Data = result.UserObject; _response.Status = true; } else { _response.Message = result.ResultCode.MessageText; _response.Status = true; } return(_response.ToHttpResponse()); }
public async Task <IActionResult> GetGamesDefault() { var Response = new ListResponse <Game>(); try { Response.Model = await _IGameRepository.GetAllGamesDefaultAsync(); Response.Message = "Querying all games with default information."; } catch (Exception ex) { Response.DidError = true; Response.Message = $"Internal Server Error. Error Message: {ex.Message}"; } _Logger.LogInfo(ControllerContext, Response.Message); return(Response.ToHttpResponse()); }
public async Task <IActionResult> Get([FromQuery] int addressId) { var response = new ListResponse <StoreResponseViewModel>(); var data = await _unit.IStore.GetStoreByAddress(addressId); if (data.HasSuccess) { response.Data = data.UserObject; response.Status = true; } else { response.Message = "Data not found"; response.Data = null; response.Status = false; } return(response.ToHttpResponse()); }
public async Task <IActionResult> Handle(GetAllUserQuery request, CancellationToken cancellationToken) { var _response = new ListResponse <UserResponseQueryModel>(); //var result = await _account.GetAllUserForFranchisee(request.CurrentUserId.Value); var result = await _account.GetAllUserForFranchisee(request); if (result.HasSuccess) { _response.Data = result.UserObject; _response.Status = true; } else { _response.Message = result.ResultCode.MessageText; _response.Status = true; } return(_response.ToHttpResponse()); }
public async Task <IActionResult> GetEmailAccountsDefault() { var Response = new ListResponse <EmailAccount>(); try { Response.Model = await _IEmailAccountRepository.GetAllEmailAccountsDefaultAsync(); Response.Message = "Querying all EmailAccounts with default information."; _Logger.LogInfo(ControllerContext, Response.Message); } catch (Exception ex) { Response.DidError = true; Response.Message = "Internal Server Error."; _Logger.LogError(ControllerContext, $"Error Message: {ex.Message}"); } return(Response.ToHttpResponse()); }