public async Task <IDataResponse <IEnumerable <CustomerModel> > > ReadAsync(Expression <Func <CustomerModel, bool> > predicate) { if (_sqliteManager.DataBase == null) { return(null); } List <CustomerModelDto> resultDto = null; IEnumerable <CustomerModel> result; if (predicate == null) { resultDto = await _sqliteManager.DataBase.Table <CustomerModelDto>().ToListAsync(); result = resultDto.ToModel(); return(new DataResponse <IEnumerable <CustomerModel> >(result, true)); } var afterParameter = Expression.Parameter(typeof(CustomerModelDto), predicate.Name); var visitor = new ExpressionExtension(predicate, afterParameter);; var newPredicate = Expression.Lambda <Func <CustomerModelDto, bool> >(visitor.Visit(predicate.Body), afterParameter); resultDto = await _sqliteManager.DataBase.Table <CustomerModelDto>() .Where(newPredicate) .ToListAsync(); result = resultDto.ToModel(); return(new DataResponse <IEnumerable <CustomerModel> >(result, true)); }
public async Task <IEnumerable <ApiResource> > FindApiResourcesByNameAsync(IEnumerable <string> apiResourceNames) { if (apiResourceNames == null) { throw new ArgumentNullException(nameof(apiResourceNames)); } List <Entities.ApiResource> apiResources = (await _context .ApiResources .WhereIn(nameof(ApiResource.Name), apiResourceNames) .GetSnapshotAsync() .ConfigureAwait(false)) .Where(x => x.Exists) .Select(x => x.ConvertTo <Entities.ApiResource>()) .ToList(); if (apiResources.Any()) { _logger.LogDebug("Found {apis} API resource in database", apiResources.Select(x => x.Name)); } else { _logger.LogDebug("Did not find {apis} API resource in database", apiResourceNames); } return(apiResources.ToModel()); }
public OperationReturnModel <CustomInventoryHeaderReturnModel> Save(List <CustomInventoryItemReturnModel> items) { OperationReturnModel <CustomInventoryHeaderReturnModel> returnValue = new OperationReturnModel <CustomInventoryHeaderReturnModel>(); returnValue.SuccessResponse = new CustomInventoryHeaderReturnModel(); // We set the branch and customer number to the proper context because the front end // Does not have any concept of this link. foreach (CustomInventoryItemReturnModel item in items) { SetCustomerNumberAndBranch(item); } try { _customInventoryRepo.SaveRange(items.ToModel()); returnValue.IsSuccess = true; returnValue.SuccessResponse.Items = _customInventoryRepo.GetItemsByBranchAndCustomer(this.SelectedUserContext.BranchId, this.SelectedUserContext.CustomerId).ToReturnModelList(); } catch (Exception ex) { returnValue.IsSuccess = false; returnValue.ErrorMessage = ex.Message; _logger.WriteErrorLog("Error saving custom inventory items", ex); } return(returnValue); }
public async Task PumpEmployees() { List <EmployeeProxy> employeeProxies = await _employeeServices.GetProxyObjects(); _databaseServices.InsertEmployees(employeeProxies.ToModel()); Log.Information("Employee Data is passed to Database Layer Successfully"); }
public void PumpApplication() { List <AppProxy> appProxies = _applicationServices.GetProxyObjects(); _databaseServices.InsertApplications(appProxies.ToModel()); Log.Information("Application data is Passed to Database Layer Successfully"); }
public void PumpCallData() { List <CallDataProxy> callDataProxies = _callDataServices.GetProxyObjects(); _databaseServices.InsertCallData(callDataProxies.ToModel()); Log.Information("Call data is Passed to Database Layer Successfully"); }
public async Task PumpCallTree() { List <CallTreeProxy> callTreeProxies = await _callTreeServices.GetProxyObjects(); _databaseServices.InsertCallTrees(callTreeProxies.ToModel()); Log.Information("CallTree data is Passed to Database Layer Successfully"); }
public object UpdateMany([FromBody] List <QualityDefinitionResource> resource) { //Read from request var qualityDefinitions = resource .ToModel() .ToList(); _qualityDefinitionService.UpdateMany(qualityDefinitions); return(Accepted(_qualityDefinitionService.All() .ToResource())); }
public OperationReturnModel <CustomInventoryHeaderReturnModel> DeleteRange(List <CustomInventoryItemReturnModel> items) { OperationReturnModel <CustomInventoryHeaderReturnModel> returnValue = new OperationReturnModel <CustomInventoryHeaderReturnModel>(); returnValue.SuccessResponse = new CustomInventoryHeaderReturnModel(); try { _customInventoryRepo.DeleteRange(items.ToModel()); returnValue.IsSuccess = true; returnValue.SuccessResponse.Items = _customInventoryRepo.GetItemsByBranchAndCustomer(this.SelectedUserContext.BranchId, this.SelectedUserContext.CustomerId).ToReturnModelList(); } catch (Exception ex) { returnValue.IsSuccess = false; returnValue.ErrorMessage = ex.Message; _logger.WriteErrorLog("Error deleting custom inventory items:", ex); } return(returnValue); }
public async Task <IActionResult> Assign(int id, List <TaskViewModel> tasks) { if (!UserIsTenantAdminOfActivity(id)) { return(new HttpUnauthorizedResult()); } var updates = tasks.ToModel(_dataAccess).ToList(); //TODO: Replacement for API like Tasks.UpdateRange(updates); foreach (var item in updates) { await _dataAccess.UpdateTaskAsync(item); } // send all notifications to the queue var smsRecipients = new List <string>(); var emailRecipients = new List <string>(); foreach (var allReadyTask in updates) { // get all confirmed contact points for the broadcast smsRecipients.AddRange(allReadyTask.AssignedVolunteers.Where(u => u.User.PhoneNumberConfirmed).Select(v => v.User.PhoneNumber)); emailRecipients.AddRange(allReadyTask.AssignedVolunteers.Where(u => u.User.EmailConfirmed).Select(v => v.User.Email)); } var command = new NotifyVolunteersCommand { // todo: what information do we add about the task? // todo: should we use a template from the email service provider? // todo: what about non-English volunteers? ViewModel = new NotifyVolunteersViewModel { SmsMessage = "You've been assigned a task from AllReady.", SmsRecipients = smsRecipients, EmailMessage = "You've been assigned a task from AllReady.", EmailRecipients = emailRecipients } }; _bus.Send(command); return(RedirectToRoute(new { controller = "Activity", Area = "Admin", action = "Details", id = id })); }
public async Task <GetProductsStoreResponse> GetProductsAsync(GetProductsStoreEntity request) { List <MongoEntity> mongoEntities = new List <MongoEntity>(); var pageSize = request.PagingInfo.PageSize; var pageNumber = request.PagingInfo.PageNumber; var collection = _db.GetCollection <MongoEntity>(_collection); var sortType = request.ProductSort.Type.ToEntity(); var skipDocuments = (pageNumber - 1) * pageSize; var orderBy = request.ProductSort.Order; var sortDefinition = (orderBy == "Asc") ? (Builders <MongoEntity> .Sort.Ascending(sortType)) : (Builders <MongoEntity> .Sort.Descending(sortType)); try { var docCount = (int)await collection.CountAsync(new BsonDocument()); request.PagingInfo.TotalPages = (docCount >= pageSize) ? ((docCount / pageSize) + ((docCount % pageSize) == 0 ? 0 : 1)) : 1; var skipDocumentEnabled = (pageNumber - 1 * pageSize) > docCount ? false : true; if (skipDocumentEnabled) { mongoEntities = await collection.Find(FilterDefinition <MongoEntity> .Empty) .Skip(skipDocuments) .Limit(pageSize) .Sort(sortDefinition) .ToListAsync(); } } catch { throw new BaseException(int.Parse(ErrorCode.DataBaseDown()), Error.DataBaseDown(), null, HttpStatusCode.GatewayTimeout); } return(mongoEntities.ToModel(request.PagingInfo)); }
public async Task <IActionResult> Assign(int id, List <TaskViewModel> tasks) { var currentUser = await _userManager.GetCurrentUser(Context); if (currentUser == null || !await _userManager.IsTenantAdmin(currentUser)) { return(new HttpUnauthorizedResult()); } if (!await UserIsTenantAdminOfActivity(currentUser, id)) { return(new HttpUnauthorizedResult()); } var updates = tasks.ToModel(_dataAccess).ToList(); //TODO: Replacement for API like Tasks.UpdateRange(updates); foreach (var item in updates) { await _dataAccess.UpdateTask(item); } return(RedirectToRoute(new { controller = "Activity", Area = "Admin", action = "Details", id = id })); }
/// <summary> /// Updates the contact Relationship. /// </summary> /// <param name="contactRelationship">The contact Relationship.</param> /// <returns></returns> public Response <ContactRelationshipViewModel> UpdateContactRelationship(List <ContactRelationshipViewModel> contactRelationship) { const string apiUrl = baseRoute + "UpdateContactRelationship"; var response = _communicationManager.Put <List <ContactRelationshipModel>, Response <ContactRelationshipModel> >(contactRelationship.ToModel(), apiUrl); return(response.ToViewModel()); }
/// <summary> /// To update Email for contact /// </summary> /// <param name="email"></param> /// <returns></returns> public Response <ContactEmailViewModel> AddUpdateEmail(List <ContactEmailViewModel> emails) { const string apiUrl = baseRoute + "AddUpdateEmail"; var response = communicationManager.Post <List <ContactEmailModel>, Response <ContactEmailModel> >(emails.ToModel(), apiUrl); return(response.ToViewModel()); }
/// <summary> /// Adds the contact Race. /// </summary> /// <param name="contactRace">The contact Race.</param> /// <returns></returns> public Response <ContactRaceViewModel> AddContactRace(List <ContactRaceViewModel> contactRace) { const string apiUrl = baseRoute + "AddContactRace"; var response = communicationManager.Post <List <ContactRaceModel>, Response <ContactRaceModel> >(contactRace.ToModel(), apiUrl); return(response.ToViewModel()); }
/// <summary> /// 角色绑定权限 /// </summary> /// <param name="roleId"></param> /// <param name="rolePermissionList"></param> /// <returns></returns> public bool BindPermission(Guid roleID, List <RolePermissionVM> rolePermissionList) { return(_roleBizService.BindPermission(roleID, rolePermissionList.ToModel())); }
/// <summary> /// Add update address /// </summary> /// <param name="contactID"></param> /// <param name="addressModel"></param> /// <returns></returns> public Response <ContactAddressViewModel> AddUpdateAddress(List <ContactAddressViewModel> addressModel) { const string apiUrl = baseRoute + "AddUpdateAddress"; var response = communicationManager.Post <List <ContactAddressModel>, Response <ContactAddressModel> >(addressModel.ToModel(), apiUrl); return(response.ToViewModel()); }
public async Task<IActionResult> Assign(int id, List<TaskViewModel> tasks) { var currentUser = await _userManager.GetCurrentUser(Context); if (currentUser == null) { return new HttpUnauthorizedResult(); } if (!await UserIsTenantAdminOfActivity(currentUser, id)) { return new HttpUnauthorizedResult(); } var updates = tasks.ToModel(_dataAccess).ToList(); //TODO: Replacement for API like Tasks.UpdateRange(updates); foreach (var item in updates) { await _dataAccess.UpdateTask(item); } return RedirectToRoute(new { controller = "Activity", Area = "Admin", action = "Details", id = id }); }
public object Import([FromBody] List <MovieResource> resource) { var newMovies = resource.ToModel(); return(_addMovieService.AddMovies(newMovies).ToResource(0)); }
/// <summary> /// Updates the contact alias. /// </summary> /// <param name="contactAlias">The contact alias.</param> /// <returns></returns> public Response <ContactAliasViewModel> UpdateContactAlias(List <ContactAliasViewModel> contactAlias) { const string apiUrl = baseRoute + "UpdateContactAlias"; var response = communicationManager.Put <List <ContactAliasModel>, Response <ContactAliasModel> >(contactAlias.ToModel(), apiUrl); return(response.ToViewModel()); }
/// <summary> /// Adds and update addresses. /// </summary> /// <param name="referral">The referral.</param> /// <returns></returns> public Response <ReferralAddressViewModel> AddUpdateAddresses(List <ReferralAddressViewModel> referral) { const string apiUrl = baseRoute + "AddUpdateAddresses"; var response = communicationManager.Post <List <ReferralAddressModel>, Response <ReferralAddressModel> >(referral.ToModel(), apiUrl); return(response.ToViewModel()); }
public PriceResponse Price(string sessionId, AirItinerary airItinerary, List<Charge> charges) { IFlightProvider flightProvider = FlightProviderFactory.GetFlightProvider(); var response = new PriceResponse(); if (airItinerary != null) { try { string errorMessage; decimal chargeAmount; if (flightProvider.Price(airItinerary.ToModel(), charges.ToModel(), out errorMessage, out chargeAmount)) { response.IsSuccess = true; response.DisplayChargeAmount = chargeAmount; response.Currency = airItinerary.AirFare.Currency; response.PaymentUrl = "testURL"; response.PaymentPostData = "testData"; } else { response.IsSuccess = false; response.ErrorMessage = errorMessage; } } catch (Exception exception) { response.IsSuccess = false; response.ErrorMessage = "Something is not quite right here. Please try again later."; Logger.LogException(exception, Source, "Price", Severity.Critical); } } return response; }
public BookResponse Book(string authenticationId, string sessionId, AirItinerary airItinerary, List<Passenger> passengers, List<Charge> charges) { IFlightProvider flightProvider = FlightProviderFactory.GetFlightProvider(); var response = new BookResponse(); var authenticationProvider = AuthenticationProviderFactory.GetAuthenticationProvider(); var accountId = authenticationProvider.GetAccountId(authenticationId); var accountProvider = AccountProviderFactory.GetAccountProvider(); ISessionProvider sessionProvider = SessionProviderFactory.GetSessionProvider(); string errorMessage; SessionData sessionData = sessionProvider.GetSession(authenticationId, sessionId, out errorMessage); if (!string.IsNullOrEmpty(accountId) && airItinerary != null && charges != null && charges.Count > 0) { try { Booking booking; errorMessage = string.Empty; if (flightProvider.Book(sessionData.Request.RequestId, airItinerary.ToModel(), passengers.ToModel(), charges.ToModel(), accountProvider.GetAccount(accountId), out errorMessage, out booking) && string.IsNullOrEmpty(errorMessage)) { response.IsSuccess = true; response.Charges = charges; response.Itinerary = airItinerary; response.Passengers = passengers; response.Pnr = booking.FlightBookings[0].Pnr; response.TicketNumbers = booking.TicketNumbers; } else { response.IsSuccess = false; response.ErrorMessage = errorMessage; } } catch (Exception exception) { response.IsSuccess = false; response.ErrorMessage = "Something is not quite right here. Please try again later."; Logger.LogException(exception, Source, "Book", Severity.Critical); } } if (!response.IsSuccess) { IEmailProvider emailProvider = EmailProviderFactory.GetEmailProvider(); emailProvider.SendBookingFailureNotificationEmail(sessionData.Request.RequestId, sessionId, response.ErrorMessage); } return response; }
public async Task<IActionResult> Assign(int id, List<TaskViewModel> tasks) { if (!UserIsTenantAdminOfActivity(id)) { return new HttpUnauthorizedResult(); } var updates = tasks.ToModel(_dataAccess).ToList(); //TODO: Replacement for API like Tasks.UpdateRange(updates); foreach (var item in updates) { await _dataAccess.UpdateTaskAsync(item); } // send all notifications to the queue var smsRecipients = new List<string>(); var emailRecipients = new List<string>(); foreach (var allReadyTask in updates) { // get all confirmed contact points for the broadcast smsRecipients.AddRange(allReadyTask.AssignedVolunteers.Where(u => u.User.PhoneNumberConfirmed).Select(v => v.User.PhoneNumber)); emailRecipients.AddRange(allReadyTask.AssignedVolunteers.Where(u => u.User.EmailConfirmed).Select(v => v.User.Email)); } var command = new NotifyVolunteersCommand { // todo: what information do we add about the task? // todo: should we use a template from the email service provider? // todo: what about non-English volunteers? ViewModel = new NotifyVolunteersViewModel { SmsMessage = "You've been assigned a task from AllReady.", SmsRecipients = smsRecipients, EmailMessage = "You've been assigned a task from AllReady.", EmailRecipients = emailRecipients, Subject = "You've been assigned a task from AllReady." } }; _bus.Send(command); return RedirectToRoute(new { controller = "Activity", Area = "Admin", action = "Details", id = id }); }
public object AddExclusions([FromBody] List <ImportExclusionsResource> resource) { var newMovies = resource.ToModel(); return(_exclusionService.AddExclusions(newMovies).ToResource()); }
/// <summary> /// 用户绑定角色 /// </summary> /// <param name="roleId"></param> /// <param name="rolePermissionList"></param> /// <returns></returns> public bool BindRole(Guid userID, List <SysUserRoleVM> userRoleList) { return(_sysUserBizService.BindRole(userID, userRoleList.ToModel())); }