public ActionResult DeleteTweet(int tweetId) { AppRepository repo = new AppRepository(); repo.DeleteTweet(tweetId); return(RedirectToAction("Index")); //, new { EdittweetId = tweetId } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Create_Click(object sender, RoutedEventArgs e) { var data = new StringBuilder(); var converter = new RomanTableConverter(); string parent; using (var src = new FileOperator(this.cFile.Text)) { if (!src.Exists()) { MessageBox.Show("invalid input file"); return; } parent = src.FileDir; src.OpenForRead(); while (!src.Eof) { data.AppendLine(converter.Convert(src.ReadLine())); } } using (var dest = new FileOperator(parent + @"\mapping.html")) { var template = new FileOperator(OsnCsLib.Common.Util.GetAppPath() + @"Res\index.html").ReadAll(); dest.Delete(); dest.OpenForWrite(); dest.Write(template.Replace("<!--container-->", data.ToString())); } var settings = AppRepository.GetInstance(); settings.ConvertFile = this.cFile.Text; settings.Save(); }
public EmbeddedResource GetFile(string path) { if (!path.Contains('/')) { return(null); } var slashIndex = path.IndexOf('/'); var componentId = path.Substring(0, slashIndex); var localPath = path.Substring(slashIndex + "/".Length); foreach (var app in AppRepository.GetAll().Where(c => c.Component.Id.Equals(componentId, StringComparison.InvariantCultureIgnoreCase))) { if (app.Scripts.Any(s => s.LocalPath.Equals(localPath, StringComparison.InvariantCultureIgnoreCase))) { return(EmbeddedResourceProvider.GetFile(path)); } if (app.Styles.Any(s => s.LocalPath.Equals(localPath, StringComparison.InvariantCultureIgnoreCase))) { return(EmbeddedResourceProvider.GetFile(path)); } if (app.Resources.Any(s => s.LocalPath.Equals(localPath, StringComparison.InvariantCultureIgnoreCase))) { return(EmbeddedResourceProvider.GetFile(path)); } } return(null); }
public async Task AddRentModel(AppRepository appRepository, RentModel rentModel) { var neededRentModel = await appRepository.RentModels.FirstOrDefaultAsync(x => x.Id == rentModel.Id); if (neededRentModel == null) { return; } if (HolderRentModels == null) { HolderRentModels = new List <HolderRentModel>(); } if (HolderRentModels.Any(x => x.RentModel.Id == rentModel.Id)) { return; } var rentModelsList = this.HolderRentModels.ToList(); rentModelsList.Add(new HolderRentModel() { RentModel = neededRentModel, HolderModel = this }); this.HolderRentModels = rentModelsList; appRepository.Entry(this).Collection(x => x.HolderRentModels).IsModified = true; await appRepository.SaveChangesAsync(); }
public OnboardingViewModel(IXDSSecService xdsCryptoService, AppRepository appRepository, DeviceVaultService deviceVaultService) { this.xdsCryptoService = xdsCryptoService; this.appRepository = appRepository; this.deviceVaultService = deviceVaultService; this.Name = ProfileViewModel.DefaultUsername; }
/// <summary> /// initialize app /// </summary> private void Initialize() { // initialize var settings = AppRepository.Init(Constants.SettingFile); this.cNormalKeyMapping.DataContext = new KeyMappingViewModel(); this.cFnKeyMapping.DataContext = new KeyMappingViewModel(); // read mapping information using (var reader = new FileOperator(Constants.KeyMappingFIle, FileOperator.OpenMode.Read)) { while (!reader.Eof) { var pair = reader.ReadLine().Split('\t'); if (this._keyMapping.ContainsKey(int.Parse(pair[0]))) { ErrorMessage.Show(ErrMsgId.MappingKeyIsDuplicated); break; } else { this._keyMapping.Add(int.Parse(pair[0]), pair[1].Replace("@r@", "\r\n")); } } } // set dip siwtch text color this._onBg = this.GetColorFromRgb("#7373FF"); this._offBg = this.GetColorFromRgb("#DDDDDD"); // restore if possible this.ShowKeyMapping(settings.HskFile); }
public void GetTenantsTest() { IAppRepository tenantsRepo = new AppRepository(MockDbCOntext); var tenants = tenantsRepo.GetTenants(); Assert.IsTrue(tenants.Any()); }
public async Task GetTenantsAsyncTest() { IAppRepository tenantsRepo = new AppRepository(MockDbCOntext); var tenants = await tenantsRepo.GetTenantsAsync(); Assert.IsTrue(tenants.Any()); }
private TweetModel GetTweet(string userName, int tweetId) { TweetModel model = new TweetModel(); AppRepository repo = new AppRepository(); model.TweetMessage = new TweetMessage(); var Tweets = repo.GetAllTweets(userName); var tweetDetails = repo.GetTweetMessageDetails(userName); if (tweetId == 0) { model.TweetMessage.User_Id = userName; } else { model.TweetMessage = Tweets.Where(x => x.Tweet_Id == tweetId).FirstOrDefault(); } model.lstTweetMessage = Tweets; model.TotalTweets = tweetDetails.TotalTweets; model.TotalFollowing = tweetDetails.TotalFollowing; model.TotalFollowers = tweetDetails.TotalFollowers; return(model); }
public MainWindow() { InitializeComponent(); this.Activated += (sender, e) => { this.cSearchWord.Focus(); }; this.Loaded += (sender, e) => { var setting = AppRepository.GetInstance(); Util.SetWindowXPosition(this, setting.Pos.X); Util.SetWindowYPosition(this, setting.Pos.Y); this._isLoaded = true; }; this._api.TranslateApiSuccess += TranslationApiSuccess; this._api.SaveApiSuccess += SaveApiSuccess; this._api.GetListApiSuccess += GetListApiSuccess; this._api.ApiFailure += TranslationApiFailure; this._api.ApiStart += TranslationApiStart; this._api.ApiStop += TranslationApiStop; if (0 < AppRepository.GetInstance().TranslationApi?.Length) { this._api.List(); } }
public Order GetOrder() { var repo = new AppRepository(); return(repo.Orders() .FirstOrDefault(p => p.Id == this.Order.Id)); }
public Category GetCategory() { var repo = new AppRepository(); return(repo.Categories() .FirstOrDefault(p => p.Id == this.Category.Id)); }
public void When_EnsureBandExists_is_called_and_no_Band_exists_then_AddBand_on_the_AppRepository_is_called_with_a_newly_created_Band() { Band band = null; AppRepository .Expect(repository => repository.GetAllBands()) .Return(new List <Band>()) .Repeat.Once(); AppRepository .Expect(repository => repository.AddBand(Arg <Band> .Is.NotNull)) .WhenCalled(invocation => { band = (Band)invocation.Arguments[0]; }) .Return(band) .Repeat.Once(); AppRepository.Replay(); var result = Process.EnsureBandExists(); Assert.IsNotNull(band); Assert.IsNotNull(result); Assert.AreEqual(band.Id, result.Id); Assert.IsFalse(string.IsNullOrEmpty(result.Passphrase)); Assert.IsFalse(string.IsNullOrEmpty(result.InitVector)); Assert.IsFalse(string.IsNullOrEmpty(result.SaltValue)); AppRepository.VerifyAllExpectations(); }
public RegistrationModel(ISmsService smsService, AppRepository appRepository) { _smsService = smsService; _appRepository = appRepository; //var dude = _appRepository.Costumers.Include(x => x.CardBindings).FirstOrDefault(x => x.Phone.Contains("443")); //var foo = _appRepository.CardBidnings.FirstOrDefault(x => x.BindingId == "2687f56c-000f-5000-8000-18421823560d"); //var client = new Client(shopId: Strings.YandexShopId, secretKey: Strings.YandexAPIKey); //client.CreatePayment(new NewPayment //{ // Amount = new Amount { Currency = "RUB", Value = new decimal(250) }, // PaymentMethodId = "2687f56c-000f-5000-8000-18421823560d", // Capture = true, // Description = "Списание 250 руб. за использование паувербанка более 5-ти дней", // Confirmation = new Confirmation // { // Type = ConfirmationType.Redirect, // ReturnUrl = "" // }, //}); //var dude1 = _appRepository.Costumers.Include(x => x.Sessions).ThenInclude(x => x.Powerbank).FirstOrDefault(x => x.Phone.Contains("225")); //var dude2 = _appRepository.Costumers.Include(x => x.Sessions).ThenInclude(x => x.Powerbank).FirstOrDefault(x => x.Phone.Contains("071")); //var mirzo = _appRepository.Costumers.Include(x => x.Sessions).ThenInclude(x => x.Powerbank).FirstOrDefault(x => x.Phone.Contains("+7 (123) 123 12 34")); }
public UserService(ModelManagementContext context = null) : base(context) { var appContext = context ?? new ModelManagementContext(); _appRepository = new AppRepository(appContext); _mapper = new ObjectMapper(); }
public PhotonWalletManager(ILoggerFactory loggerFactory, AppRepository appRepository, ITcpConnection tcpConnection, INetworkClient networkClient) { this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.appRepository = appRepository; this.tcpConnection = tcpConnection; this.networkClient = networkClient; }
} //1 - Hour 2 - Day 3 - First Hour Free public EdutModel(AppRepository appRepository, IGeocodeService geocode) { _appRepository = appRepository; _geocode = geocode; PayAvialabilities = new List <int>(); }
public async Task <AppModel> Update(string clientId, AppModel app) { if (string.IsNullOrEmpty(app.UpdateBy)) { throw new CallerException("UpdateBy is required"); } var appToUpdate = await GetApp(clientId); if (appToUpdate == null) { throw new CallerException("App not found"); } app.ClientId = clientId; Validate(app, !string.IsNullOrEmpty(appToUpdate.ClientSecret)); AppModel updatedApp; using (var uow = new UnitOfWork(Context)) { var repo = new AppRepository(uow); updatedApp = await repo.Update(app); } await AppCache.InvalidateAppCache(updatedApp.ClientId); return(updatedApp); }
protected ViewModelBase(IMessageBoxService messageBoxService, IEventAggregator eventAggregator, AppRepository appRepository, IoCProxy ioc) { MessageBoxService = messageBoxService; AppRepository = appRepository; EventAggregator = eventAggregator; IoC = ioc; }
public Supplier GetSupplier() { var repo = new AppRepository(); return(repo.Suppliers() .FirstOrDefault(p => p.Id == this.Supplier.Id)); }
static void RunScheduledAction(object state) { var s = (TimerState)state; s.Counter++; Console.WriteLine("{0} Running scheduled action {1}.", DateTime.UtcNow.TimeOfDay, s.Counter); if (s.ActionSchedule.StopDateTime != DateTime.MinValue && s.ActionSchedule.StopDateTime <= DateTime.UtcNow) { Console.WriteLine("disposing of timer..."); s.Timer.Dispose(); s.Timer = null; } else { AppRepository.RunAction(s.ActionSchedule.AppName, s.ActionSchedule.ActionName); var nextRunDate = DateTime.UtcNow.AddSeconds(s.ActionSchedule.IntervalAsSeconds()); //update timers due time to trigger the next run s.Timer.Change(nextRunDate - DateTime.UtcNow, TimeSpan.FromMilliseconds(-1)); //update schedule with next run date s.ActionSchedule.NextRun = nextRunDate; ActionScheduleRepository.SaveActionSchedule(s.ActionSchedule); } }
//============================================================================== public OrderOutAddNewViewModel( AppRepository <KfsContext> aAppDbRepository, TDStransactionControl aTDStransactionControl) : base(aAppDbRepository, aTDStransactionControl) { _myView = new OrderOutAddNewView(); _myView.DataContext = this; Command_NavigatBack = new RelayCommand(NavigateBack); Command_ToMainMenu = new RelayCommand(NavigateToMainMenu); Command_Save = new RelayCommand(SaveToDB, CanSaveToDB); Command_SeeInvoice = new RelayCommand(SeeInvoice, CanSeeInvoice); Command_NewClient = new RelayCommand(NavigateToNewclient); Command_ClearOrder = new RelayCommand(ClearOrder); Command_DataGridProductsButtonclick = new RelayCommand(DataGridProductsButtonclick); Command_DataGridOrdersButtonclick = new RelayCommand(DataGridOrdersButtonclick); //moeilijk doen over ICollection :-( ClientsAll = _appDbRespository.Client.GetAllClientsWithAdress(); foreach (Client clnt in ClientsAll) { clnt.CltAddresssAsList = clnt.CltAddresss.ToList(); } RefreshData(); }
public async Task <AppModel> GetApp(string clientId) { var cacheResult = await AppCache.GetAppFromCache(clientId); if (cacheResult != null) { return(cacheResult); } AppModel app; using (var uow = new UnitOfWork(Context)) { var repo = new AppRepository(uow); app = await repo.GetAll().Where(c => c.ClientId == clientId).FirstOrDefaultAsync(); } if (app != null) { await AppCache.AddAppToCache(clientId, app); } return(app); }
public dynamic Execute() { var repo = new AppRepository(); var categories = repo.Categories(); return(categories.Select(p => p.Name).ToArray()); }
public void TestDatabase() { if (this.GetCurrentViewModel() is MYOBSettingsViewModel myobSettingsViewModel) { AppRepository Pile_MYOB = new AppRepository(Database, slack); _model.MyobDatabaseName = myobSettingsViewModel.IsDBName; _model.MyobServerName = myobSettingsViewModel.IsServerName; Pile_MYOB.Settings.MyobServerName = _model.MyobServerName; Pile_MYOB.Settings.MyobDatabaseName = _model.MyobDatabaseName; if (_model.MyobServerName == "" || _model.MyobServerName == null || _model.MyobDatabaseName == "" || _model.MyobDatabaseName == null) { MessageBox.Show("Warning: you didn't enter server name or database name.", "FYIStockPile", MessageBoxButton.OK, MessageBoxImage.Warning); } else { if (MYOB.ConnectionTest(Pile)) { Pile_MYOB.Save(); // save MYOB Settings // MessageBox.Show("Connect Test: Success", "FYIStockPile", MessageBoxButton.OK, MessageBoxImage.Information); SelectFolder(); } else { MessageBox.Show("Connect Test: Error", "FYIStockPile", MessageBoxButton.OK, MessageBoxImage.Error); } } } }
//============================================================================================================== public QuatationsViewModel(AppRepository <KfsContext> aAppDbRepository, TDStransactionControl aTDStransactionControl) : base(aAppDbRepository, aTDStransactionControl) { _myView = new QuatationsView(); _myView.DataContext = this; //(_myView as QuatationsView).haha.DataContext = this; Command_NavigatBack = new RelayCommand(NavigateBack); Command_ToMainMenu = new RelayCommand(NavigateToMainMenu); watcher.Path = PATH_PENDING; watcher.Created += new FileSystemEventHandler(OnPendingFilesChanged); watcher.Deleted += new FileSystemEventHandler(OnPendingFilesChanged); watcher.EnableRaisingEvents = true; Command_MakeJson = new RelayCommand(MakeJsonSjabloon, CanMakeJsonSjabloon); Command_NewProduct = new RelayCommand(AddNewProduct, CanAddNewProduct); Command_ConfirmQuatation = new RelayCommand(ConfirmQuatation, CanConfirmQuatation); SuppliersAll = aAppDbRepository.Supplier.GetAll().ToList(); //TestString = "joske"; //Command_test = new RelayCommand(testcoommand); LoadPendingJsonFiles(); }
private void CheckIfDeafultAppsHaveBeenInstalled() { if (AppRepository.GetByName("Text") == null) { _appInstallationService.InstallDefaultApps(); } }
public async Task <AppModel> Create(AppModel app, bool createSecret) { if (string.IsNullOrEmpty(app.UpdateBy)) { throw new CallerException("UpdateBy is required"); } app.ClientId = GenerateKey(10); if (createSecret) { app.ClientSecret = GenerateKey(40); } else { app.ClientSecret = ""; } Validate(app, createSecret); using (var uow = new UnitOfWork(Context)) { var repo = new AppRepository(uow); return(await repo.Create(app)); } }
public dynamic Execute() { var repo = new AppRepository(); var suppliers = repo.Suppliers(); return(suppliers.Select(p => p.Name).ToArray()); }
public LoginScreen(AppRepository appRepository) { InitializeComponent(); StartPosition = FormStartPosition.CenterScreen; _appRepository = appRepository; _loginManager = new LoginManager(appRepository.UserRepository); }
public void RepositoryCreateMethod_ShoudSaveInDatabase() { var itemToAdd = this.GetValidItem("Create"); var currentRepository = new AppRepository<TestEntity>(this.databaseContext); currentRepository.Add(itemToAdd); currentRepository.SaveChanges(); var itemInDatabase = currentRepository.Find(itemToAdd.Id); Assert.IsNotNull(itemInDatabase); Assert.AreEqual(itemToAdd.Id, itemInDatabase.Id); }
public void RepositoryUpdateMethod_ShoudUpdateItemInDatabase() { var itemToAdd = this.GetValidItem("Update"); var currentRepository = new AppRepository<TestEntity>(this.databaseContext); currentRepository.Add(itemToAdd); currentRepository.SaveChanges(); var itemInDatabase = currentRepository.Find(itemToAdd.Id); itemInDatabase.Name = "Changed Name"; currentRepository.Update(itemInDatabase); currentRepository.SaveChanges(); Assert.AreEqual(itemToAdd.Name, itemInDatabase.Name); }
public void RepositoryDeleteMethod_ShoudDeleteItemFromTheDatabase() { var itemToAdd = this.GetValidItem("Delete"); var currentRepository = new AppRepository<TestEntity>(this.databaseContext); currentRepository.Add(itemToAdd); currentRepository.SaveChanges(); var itemInDatabase = currentRepository.Find(itemToAdd.Id); currentRepository.Delete(itemInDatabase); currentRepository.SaveChanges(); var deletedItem = currentRepository.Find(itemToAdd.Id); Assert.IsNull(deletedItem); }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" }); using (var _repo = new AppRepository()) { IdentityUser user = await _repo.FindUser(context.UserName, context.Password); if (user == null) { context.SetError("invalid_grant", "The user name or password is incorrect."); return; } } var identity = new ClaimsIdentity(context.Options.AuthenticationType); identity.AddClaim(new Claim("sub", context.UserName)); identity.AddClaim(new Claim("role", "user")); context.Validated(identity); }
protected override void AdditionalSetup() { base.AdditionalSetup(); Repository = new AppRepository(CatalogsContainer); }
public AccountController() { _repo = new AppRepository(); }