/// <summary> /// Get the URLs added by the Client /// </summary> public void GetURLs() { URLs.Clear(); if (Nintex.TestContext.IsTesting == true) { URLs.Add(new URL { Id = 1, LongURL = "www.google.com", ShortURL = "TEST" }); return; } Nintex.DataLayer.Client dbClient = new DataLayer.Client { Id = this.Id }; try { DataLayer.NintexUrlDbEntities db = new DataLayer.NintexUrlDbEntities(); URLs = db.VWClientURLs .Where(u => u.ClientId == this.Id) .Select(u => new BusinessLayer.URL { Id = u.UrlId, LongURL = u.LongURL, ShortURL = u.ShortURL }).ToList <BusinessLayer.URL>(); } catch (Exception ex) { //ignore the exception } }
/// <summary> /// Returns the client having provided LoginId and Password /// </summary> /// <param name="aLoginId"></param> /// <param name="aPassword"></param> /// <returns></returns> public static Client GetClient(string aLoginId, string aPassword) { //in case of unit-testing if (Nintex.TestContext.IsTesting == true) { return(new Client { Id = 1, LoginId = aLoginId, Name = aLoginId }); } Client client = new Client(); string pwd = Security.HashPassword(aPassword); Nintex.DataLayer.NintexUrlDbEntities db = new DataLayer.NintexUrlDbEntities(); client = db.Clients .Where(c => c.LoginId == aLoginId && c.PasswordHash == pwd) .Select(c => new BusinessLayer.Client { Id = c.Id, LoginId = c.LoginId, Name = c.Name, }).Single(); return(client); }
/// <summary> /// Adds the Client in repository /// </summary> private new void Add() { //in case of unit-testing if (Nintex.TestContext.IsTesting == true) { this.Id = 1; return; } DataLayer.Client newClient = new DataLayer.Client(); newClient.Name = this.LoginId; newClient.LoginId = this.LoginId; newClient.PasswordHash = Security.HashPassword(this.Password); DataLayer.NintexUrlDbEntities db = new DataLayer.NintexUrlDbEntities(); db.Clients.Add(newClient); //db.Entry(newClient); db.SaveChanges(); this.Id = newClient.Id; }