public JsonResult DeleteDocument(string envelopeId) { IHomeModel model = this.HydrateHomeModel(null); model.DeleteDocument(envelopeId); return(Json(envelopeId)); }
public ActionResult Index(HomeModel modelUp) { IHomeModel model = this.HydrateHomeModel(modelUp); model.RefreshDocuments(); return(View("Index", model)); }
public HomeViewModel(Func<ICancellableAlert> alertFactory, IScheduler scheduler = null, IHomeModel mod = null) { /* if (scheduler == null) scheduler = RxApp.MainThreadScheduler; var alert = alertFactory () .SetTitle ("some title") .SetMessage ("some message") ; var automaticGoAlert = alert.WhenResult .Merge ( Observable.Interval (TimeSpan.FromMilliseconds (TimerIntervalMillisec), scheduler) // the actual timer .Select (p => TimerStartTime - p - 1) // inversing countdown .StartWith (Convert.ToInt64 (TimerStartTime)) // starting so it displays 10, otherwise nothing for 1 sec .Do (sec => alert.DisplayTimeRemaining (sec.ToString ())) // updating alert .Select (sec => sec <= 0) // returns true only at end of countdown .Where (b => b) // only goes forward if true .Do (_ => alert.Close ()) // close popup ) .Take (1) // first onNext passes through then this will call onComplete ; OpenPopupCommand = ReactiveCommand.CreateAsyncTask(async _ => { alert.Open(); automaticGoAlert.Subscribe ( onNext: alertResult => { if (alertResult) alertFactory ().SetMessage ("OK").Open (); else alertFactory ().SetMessage ("Cancelled").Open (); } ); }, RxApp.MainThreadScheduler); */ /* var github = new GitHubApi (); var subscription = github.GetUserObservable ("benoitjadinon") .SubscribeOn (RxApp.TaskpoolScheduler) .Timeout (TimeSpan.FromSeconds (10)) // throws TimeOutException .DelaySubscription (TimeSpan.FromSeconds (3)) // though we subscribe directly, it'll wait for 3 seconds before doing the actual call .Do (onNext: Debug.WriteLine) // debugs the actual call result .Delay (TimeSpan.FromSeconds (2)) // will hold the result for 2 more seconds .Select (u => u.Login) // forwards only the login, instead of the whole User object .SelectMany (github.GetReposOwned) // do an other call .ObserveOn (scheduler) .Subscribe ( onNext: repos => Debug.WriteLine (repos[0]), onError: Debug.WriteLine ); */ //var result = await github.GetUserObservable("benoitjadinon") // .Timeout(TimeSpan.FromSeconds(10)); }
public IActionResult Index() { IHomeModel model = this.HomeService.GetModel(); // Test only. //this.Data.TestEFEntitiesRepository.Add(new Entities.TestEFEntity() { Name = "test", Value = "update2" }); //this.Data.TestEFEntitiesRepository.Save(); return(View(model)); }
public ActionResult Logout() { if (Session["login"] != null) { Session.Remove("login"); } IHomeModel model = HomeModelFactory.CreateHomeModel(); return(View("Index", model)); }
public void Init() { _fakeView = Substitute.For <IHomeView>(); _fakeModel = Substitute.For <IHomeModel>(); _uut = new HomePresenter(_fakeView, _fakeModel); _fakeModel.Cases.Returns(new List <Case>()); _fakeModel.Cases.Add(new Case() { Id = 1, Status = CaseStatus.Created, ErrorDescription = "String", Installation = new Installation() { Id = 1, Name = "Street", } }); _fakeModel.Cases.Add(new Case() { Id = 2, Status = CaseStatus.Pending, ErrorDescription = "String2", Installation = new Installation() { Id = 1, Name = "Street2", } }); _fakeModel.MyCases.Returns(new List <Case>()); _fakeModel.MyCases.Add(new Case() { Id = 3, Status = CaseStatus.Created, ErrorDescription = "String3", Installation = new Installation() { Id = 1, Name = "Street3", } }); _fakeModel.MyCases.Add(new Case() { Id = 4, Status = CaseStatus.Pending, ErrorDescription = "String4", Installation = new Installation() { Id = 1, Name = "Street4", } }); }
public ActionResult Login(HomeModel modelUp) { if (string.IsNullOrWhiteSpace(modelUp.CurrentUser)) { modelUp.ErrorMessage = "You must enter a value in order to login to the system."; return(View("Index", modelUp)); } IHomeModel model = this.HydrateHomeModel(modelUp); return(View("Index", model)); }
private ModelFactory() { _tcApi = new TCApi(); _logInModel = new LogInModel(_tcApi); _homeModel = new HomeModel(_tcApi); _userPreference = new UserPreference(_tcApi); _settingsModel = new SettingsModel(); _createUserModel = new CreateUserModel(_tcApi); _createCaseModel = new CreateCaseModel(_tcApi); _caseModel = new CaseModel(_tcApi); _changePasswordModel = new ChangePasswordModel(_tcApi); _mapModel = new MapModel(_tcApi); _trafficLightModel = new TrafficLightOverviewModel(_tcApi); }
public ActionResult SubmitDocusign(HomeModel modelUp, HttpPostedFileBase file) { IHomeModel model = this.HydrateHomeModel(modelUp); if (string.IsNullOrWhiteSpace(model.SendToEmail)) { model.ErrorMessage = "You must enter a valid Send To Email value before attempting to send a document."; return(View("Index", model)); } if (string.IsNullOrWhiteSpace(model.SendToName)) { model.ErrorMessage = "You must enter a valid Send To Name before attempting to send a document."; return(View("Index", model)); } if (model.UseSignatureXY) { if (!model.SignaturePageNumber.HasValue) { model.ErrorMessage = "If directly specifying a signature location, you must enter a valid number into the Page Number field."; return(View("Index", model)); } if (!model.SignatureX.HasValue) { model.ErrorMessage = "If directly specifying a signature location, you must enter a valid number into the X Coordinate field."; return(View("Index", model)); } if (!model.SignatureY.HasValue) { model.ErrorMessage = "If directly specifying a signature location, you must enter a valid number into the Y Coordinate field."; return(View("Index", model)); } } if (file != null && file.ContentLength > 0) { model.FileName = Path.GetFileName(file.FileName); using (MemoryStream ms = new MemoryStream()) { file.InputStream.CopyTo(ms); model.Document = ms.GetBuffer(); } model.UploadDocumentToDocuSign(); } else { model.ErrorMessage = "Either a file was not specified or it was empty. Please specify a valid file before attempting to send a document."; } return(View("Index", model)); }
public async Task<string> AddEntry(IHomeModel model) { model.Token = await _tokenService.GetToken(); if (await Exists(model, QueryType.Token)) { //Generate new token and try again. model.Token = await _tokenService.GetToken(); return await AddEntry(model); } if (await Exists(model, QueryType.Url)) { //Url already exists, return existing token. model.Token = await GetEntry(model, QueryType.Token); return BuildShortUrl(model); } return await Task.Run(async () => { using (SqlConnection con = new SqlConnection(await GetConnectionString())) { con.Open(); using (SqlCommand command = new SqlCommand("INSERT INTO [dbo].[Entry]([Url], [Token]) VALUES(@URL, @Token);", con)) { command.Parameters.Add(new SqlParameter() { ParameterName = "URL", Value = model.Url, }); command.Parameters.Add(new SqlParameter() { ParameterName = "Token", Value = model.Token, }); await command.ExecuteNonQueryAsync(); return BuildShortUrl(model); } } }); }
public ActionResult Index() { IHomeModel model = this.HomeService.GetModel(); // Test only. this.Data.TestEFEntitiesRepository.Add(new Entities.TestEFEntity() { Name = "test", Value = "update" }); this.Data.TestEFEntitiesRepository.Save(); // Test only. var forDelete = this.Data.TestEFEntitiesRepository.GetById(3); if (forDelete != null) { this.Data.TestEFEntitiesRepository.Delete(forDelete); this.Data.TestEFEntitiesRepository.Save(); } return(View(model)); }
public async Task<IValidationContext> ShortUrlValid(IHomeModel model) { string text = model.Url; return await Task.Run(() => { ValidationContext context = new ValidationContext(); if (string.IsNullOrEmpty(text)) { context.ErrorMessages.Add("Please enter a URL."); text = string.Empty; } //load url with parsed model url for further testing. text = HttpUtility.HtmlEncode(text.Trim()); if (!Regex.IsMatch(text, String.Format("(http://)({0})(/)(\\w*)(?!\\W)$", model.Host))) context.ErrorMessages.Add("Please enter a valid URL."); if (context.ErrorMessages.Count == 0) context.IsValid = true; return context; }); }
private IHomeModel HydrateHomeModel(IHomeModel receivedModel) { IHomeModel model = HomeModelFactory.CreateHomeModel(); if (receivedModel != null) { model.CurrentUser = receivedModel.CurrentUser; model.SendToEmail = receivedModel.SendToEmail; model.SendToName = receivedModel.SendToName; model.UseSignatureXY = receivedModel.UseSignatureXY; model.SignaturePageNumber = receivedModel.SignaturePageNumber; model.SignatureX = receivedModel.SignatureX; model.SignatureY = receivedModel.SignatureY; } if (string.IsNullOrWhiteSpace(model.CurrentUser)) { model.CurrentUser = Session["login"] == null ? null : Session["login"].ToString(); } else { Session.Add("login", model.CurrentUser); } return(model); }
private IHomeModel HydrateHomeModel(IHomeModel receivedModel) { IHomeModel model = HomeModelFactory.CreateHomeModel(); if (receivedModel != null) { model.CurrentUser = receivedModel.CurrentUser; model.SendToEmail = receivedModel.SendToEmail; model.SendToName = receivedModel.SendToName; model.UseSignatureXY = receivedModel.UseSignatureXY; model.SignaturePageNumber = receivedModel.SignaturePageNumber; model.SignatureX = receivedModel.SignatureX; model.SignatureY = receivedModel.SignatureY; } if(string.IsNullOrWhiteSpace(model.CurrentUser)) { model.CurrentUser = Session["login"] == null ? null : Session["login"].ToString(); } else { Session.Add("login", model.CurrentUser); } return model; }
public async Task DeleteEntry(IHomeModel model, QueryType queryType) { await Task.Run(async () => { string qt = Enum.GetName(typeof(QueryType), queryType); using (SqlConnection con = new SqlConnection(await GetConnectionString())) { con.Open(); using (SqlCommand command = new SqlCommand(string.Format("DELETE FROM [dbo].[Entry] WHERE [{0}] = @{0};", qt), con)) { command.Parameters.Add(new SqlParameter() { ParameterName = qt, Value = model.GetType().GetProperty(qt).GetValue(model, null) }); await command.ExecuteNonQueryAsync(); } } }); }
private string BuildShortUrl(IHomeModel model) { return String.Format("http://{0}/{1}", model.Host, model.Token); }
public async Task<bool> Exists(IHomeModel model, QueryType queryType) { return await Task.Run(async () => { bool exists = true; string qt = Enum.GetName(typeof(QueryType), queryType); using (SqlConnection con = new SqlConnection(await GetConnectionString())) { con.Open(); using ( SqlCommand command = new SqlCommand( string.Format("if (EXISTS (SELECT [Id] FROM [dbo].[Entry] WHERE [{0}] = @{0})) SELECT 'true' ELSE SELECT 'false'", qt), con)) { command.Parameters.Add(new SqlParameter() { ParameterName = qt, Value = model.GetType().GetProperty(qt).GetValue(model, null) }); using (SqlDataReader reader = await command.ExecuteReaderAsync()) { while (reader.Read()) { exists = bool.Parse(reader.GetString(0)); } return exists; } } } }); }
public async Task<string> GetEntry(IHomeModel model, QueryType queryType) { return await Task.Run(async () => { string valueType = Enum.GetName(typeof(QueryType), queryType); string filterType = GetFilterType(queryType); using (SqlConnection con = new SqlConnection(await GetConnectionString())) { con.Open(); using (SqlCommand command = new SqlCommand(string.Format("SELECT [{0}] FROM [dbo].[Entry] WHERE [{1}] = @{1}", valueType, filterType), con)) { command.Parameters.Add(new SqlParameter() { ParameterName = filterType, Value = model.GetType().GetProperty(filterType).GetValue(model, null) }); using (SqlDataReader reader = await command.ExecuteReaderAsync()) { while (reader.Read()) { return reader.GetString(0); } throw new Exception(string.Format("{0} {1} not found in database.", filterType, valueType)); } } } }); }
public HomeController(IHomeModel model) { homeModel = model; homeModel.Message = "The HomeModel was wired up using the Simple IoCContainer."; }
public ActionResult Index() { IHomeModel model = HomeModelFactory.CreateHomeModel(); return(View("Index", model)); }
public HomePresenter(IHomeView homeView, IHomeModel homeModel) { _homeView = homeView; _homeModel = homeModel; }
// GET: Home public ActionResult HelloWorld() { IHomeModel context = SitecoreContext.GetCurrentItem <IHomeModel>(); return(View(context)); }