public ActionResult Create(FormCollection form) { try { if (String.IsNullOrEmpty(form["Name"])) ModelState.AddModelError("Name", "The Name field is required"); Models.Client client = new Models.Client(); UpdateModel(client); // Test this here rather than further up so we get the errors from update model even // if the manual validation fails if (!ModelState.IsValid) throw new InvalidOperationException("Input failed model validation"); client.ClientId = Guid.NewGuid(); client.Save(); return RedirectToAction("Index"); } catch { return View(); } }
public dynamic addClient(EmpClientModel empClient) { db.Configuration.ProxyCreationEnabled = false; Models.Client newClient = new Models.Client(); newClient.ClientLogoURL = "0.png"; newClient.ClientName = empClient.clientName; int? empCompanyId = db.Employees.Find(empClient.orgEmpId).CompanyId; newClient.OrgId = db.Organizations.Find(empCompanyId).OrgId; EmpClient ec = new EmpClient(); ec.ClientId = newClient.ClientId; ec.EmpId = empClient.orgEmpId; newClient.EmpClients.Add(ec); db.Clients.Add(newClient); return db.SaveChanges(); }
public static Models.Client GetCliente(string codCliente) { GcpBECliente objCli = new GcpBECliente(); Models.Client myCli = new Models.Client(); if (PriEngine.InitializeCompany(SINFDashboard360.Properties.Settings.Default.Company.Trim(), SINFDashboard360.Properties.Settings.Default.User.Trim(), SINFDashboard360.Properties.Settings.Default.Password.Trim()) == true) { if (PriEngine.Engine.Comercial.Clientes.Existe(codCliente) == true) { objCli = PriEngine.Engine.Comercial.Clientes.Edita(codCliente); myCli.client_id = objCli.get_Cliente(); myCli.name = objCli.get_Nome(); myCli.currency = objCli.get_Moeda(); myCli.tax_number = objCli.get_NumContribuinte(); myCli.address = objCli.get_Morada(); return myCli; } else { return null; } } else return null; }
public ActionResult Delete(string id, FormCollection collection) { try { Models.Client client = new Models.Client(new Guid(id)); client.Delete(); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(string id, FormCollection form) { try { Models.Client client = new Models.Client(new Guid(id)); UpdateModel(client); client.Save(); return RedirectToAction("Index"); } catch { return View(); } }
public async Task When_Passing_Jws_With_Invalid_Header_To_DecryptAsync_Then_Empty_Is_Returned() { // ARRANGE InitializeFakeObjects(); var client = new Models.Client(); _jwsParserMock.Setup(j => j.GetHeader(It.IsAny <string>())) .Returns(() => null); _clientRepositoryStub.Setup(c => c.GetClientByIdAsync(It.IsAny <string>())) .Returns(Task.FromResult(client)); // ACT var result = await _jwtParser.DecryptAsync("jws", "client_id"); // ASSERT Assert.Empty(result); }
public ActionResult Delete(int id, FormCollection collection) { try { // TODO: Add delete logic here Models.Client theClient = database.Clients.SingleOrDefault(c => c.client_id == id); database.Clients.Remove(theClient); database.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task When_A_Valid_Jws_Token_Is_Passed_To_AuthenticateClientWithPrivateKeyJwt_Then_Client_Is_Returned() { // ARRANGE InitializeFakeObjects(); var instruction = new AuthenticateInstruction { ClientAssertion = "invalid_header.invalid_payload" }; var jwsPayload = new JwsPayload { { Jwt.Constants.StandardClaimNames.Issuer, "issuer" }, { Jwt.Constants.StandardResourceOwnerClaimNames.Subject, "issuer" }, { Jwt.Constants.StandardClaimNames.Audiences, new [] { "audience" } }, { Jwt.Constants.StandardClaimNames.ExpirationTime, DateTime.UtcNow.AddDays(2).ConvertToUnixTimestamp() } }; var client = new Models.Client(); _jwtParserFake.Setup(j => j.IsJwsToken(It.IsAny <string>())) .Returns(true); _jwsParserFake.Setup(j => j.GetPayload(It.IsAny <string>())) .Returns(jwsPayload); _jwtParserFake.Setup(j => j.UnSignAsync(It.IsAny <string>(), It.IsAny <string>())) .Returns(Task.FromResult(jwsPayload)); _clientRepositoryStub.Setup(c => c.GetClientByIdAsync(It.IsAny <string>())) .Returns(Task.FromResult(client)); _simpleIdentityServerConfiguratorFake.Setup(s => s.GetIssuerNameAsync()) .Returns(Task.FromResult("audience")); // ACT var result = await _clientAssertionAuthentication.AuthenticateClientWithPrivateKeyJwtAsync(instruction); // ASSERT Assert.NotNull(result.Client); }
private void Crediter(Res response, Client value) { SqlConnection connection = Models.Connexion.Get("Server=localhost;Database=foot;User ID=sa;Password=itu;"); Models.ClientDAO cldao = new Models.ClientDAO(connection); Models.Client client = cldao.SelectOne("WHERE id='" + value.id + "' AND password='******'"); if (client != null) { client.Solde += value.solde; cldao.Update(client); response.error = false; } else { throw new Exception("Votre pseudo ou mots de passe est errone !"); } }
public void Map() { // Arrange var mapperConfiguration = new MapperConfiguration(expression => { expression.AddProfile <ClientMapperProfile>(); }); var mapper = new AutoMapperWrapper(new Mapper(mapperConfiguration)); var model = new Models.Client(); // Act var entity = mapper.Map <Entities.Client>(model); model = mapper.Map <Models.Client>(entity); // Assert Assert.NotNull(entity); Assert.NotNull(model); mapperConfiguration.AssertConfigurationIsValid(); }
public Models.StoredGrant Find(string subject, Models.Client client, Models.Application application, IEnumerable <Scope> scopes, StoredGrantType type) { var grants = db.StoredGrants.Where(h => h.Subject == subject && h.Client.ClientId == client.ClientId && h.Application.ID == application.ID && h.Type == type).ToList(); foreach (var grant in grants) { if (grant.Scopes.ScopeEquals(scopes)) { return(grant); } } return(null); }
public void When_Checking_Client_Grant_Types_Then_False_Is_Returned() { // ARRANGE InitializeMockingObjects(); var client = new Models.Client { GrantTypes = new List <GrantType> { GrantType.@implicit, GrantType.password } }; // ACTS & ASSERTS Assert.False(_clientValidator.CheckGrantTypes(client, GrantType.refresh_token)); Assert.False(_clientValidator.CheckGrantTypes(client, GrantType.refresh_token, GrantType.password)); }
public ActionResult Index() { ViewBag.Title = "Home Page"; //Models.Client _client = (new Provider.MongoDBProvider<Models.Client>()).Find("{ name : 'Nico' }", "Client"); Models.Client _client = (new Provider.MongoDBProvider <Models.Client>()).GetbyId(2, "Client"); ViewBag.Title = _client.Name; _client.Name = "nico2"; _client.Values["Date"] = System.DateTime.Now; _client.EntityName = "Client"; (new Provider.MongoDBProvider <Models.Client>()).Update(_client); return(View()); }
public async Task <ActionResult <int> > Update([FromBody] Models.Client client) { try { if (ModelState.IsValid) { return(await _iClient.UpdateClient(client)); } return(BadRequest()); } catch (Exception) { //'500' means Internal Server Error return(StatusCode(500)); } }
public void When_Checking_Client_Has_Implicit_Grant_Type_Then_True_Is_Returned() { // ARRANGE InitializeMockingObjects(); var client = new Models.Client { GrantTypes = new List <GrantType> { GrantType.@implicit } }; // ACT var result = _clientValidator.CheckGrantTypes(client, GrantType.@implicit); // ASSERTS Assert.True(result); }
public async Task When_Passing_Jws_With_Invalid_Header_To_Function_Unsign_Then_Null_Is_Returned() { // ARRANGE const string clientId = "client_id"; var client = new Models.Client(); InitializeFakeObjects(); _clientRepositoryStub.Setup(c => c.GetClientByIdAsync(It.IsAny <string>())) .Returns(Task.FromResult(client)); _jwsParserMock.Setup(j => j.GetHeader(It.IsAny <string>())) .Returns(() => null); // ACT var result = await _jwtParser.UnSignAsync("jws", clientId); // ASSERT Assert.Null(result); }
private void ValidateModel(Models.Client client) { if (client == null) { throw new ArgumentNullException(nameof(client)); } if (String.IsNullOrEmpty(client.Name)) { throw new ArgumentException("Name of client is required", nameof(client.Name)); } if (client.CountryId == Guid.Empty) { throw new ArgumentException("Country of client is required", nameof(client.CountryId)); } }
public List <Models.Client> GetAllClients() { List <Models.Client> resultList = new List <Models.Client>(); Bank.services.BankClient[] bankClients = proxy.GetAllClients(); foreach (Bank.services.BankClient bankClient in bankClients) { String[] clientName = bankClient.ClientName.Split(new char[] { ',' }); Models.Client client = new Models.Client() { IDClient = bankClient.ClientID, FirstName = clientName[0], LastName = clientName[1] }; resultList.Add(client); } return(resultList); }
private void txtCliente_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (txtCliente.Text != "") { Models.Client clientes = new Models.Client(); using (clientes) { List <Models.Client> cliente = clientes.getClientbyName(txtCliente.Text); if (cliente.Count > 0) { txtIdCliente.Text = cliente[0].Id.ToString(); } } } } }
public bool TryGetClient(string clientId, out Models.Client client) { using (var entities = IdentityServerConfigurationContext.Get()) { var record = (from c in entities.Clients where c.ClientId.Equals(clientId, StringComparison.Ordinal) select c).SingleOrDefault(); if (record != null) { client = record.ToDomainModel(); return(true); } client = null; return(false); } }
public void Add_passes_through() { var cmdletMock = CmdletMock.CreateMock(); var ctxName = Guid.NewGuid().ToString(); var newClient = new Models.Client { ClientId = "MyClientId" }; using (var ctx = _dbContextFixture.GetContext(ctxName)) { var controller = new ClientController(ctx, cmdletMock.Object); controller.AddClient(newClient, true); } cmdletMock.Verify(cmdlet => cmdlet.WriteObject(newClient), Times.Exactly(1)); }
public static Entities.Client ToEntity(this Models.Client s) { if (s == null) { return(null); } if (s.ScopeRestrictions == null) { s.ScopeRestrictions = new List <string>(); } if (s.RedirectUris == null) { s.RedirectUris = new List <Uri>(); } return(Mapper.Map <Models.Client, Entities.Client>(s)); }
public async Task When_A_Jws_Token_With_Invalid_Audience_Is_Passed_To_AuthenticateClientWithPrivateKeyJwt_Then_Null_Is_Returned() { // ARRANGE InitializeFakeObjects(); var instruction = new AuthenticateInstruction { ClientAssertion = "invalid_header.invalid_payload" }; var jwsPayload = new JwsPayload { { Jwt.Constants.StandardClaimNames.Issuer, "issuer" }, { Jwt.Constants.StandardResourceOwnerClaimNames.Subject, "issuer" }, { Jwt.Constants.StandardClaimNames.Audiences, new [] { "audience" } } }; var client = new Models.Client(); _jwtParserFake.Setup(j => j.IsJwsToken(It.IsAny <string>())) .Returns(true); _jwsParserFake.Setup(j => j.GetPayload(It.IsAny <string>())) .Returns(jwsPayload); _jwtParserFake.Setup(j => j.UnSignAsync(It.IsAny <string>(), It.IsAny <string>())) .Returns(Task.FromResult(jwsPayload)); _clientRepositoryStub.Setup(c => c.GetClientByIdAsync(It.IsAny <string>())) .Returns(Task.FromResult(client)); _simpleIdentityServerConfiguratorFake.Setup(s => s.GetIssuerNameAsync()) .Returns(Task.FromResult("invalid_issuer")); // ACT var result = await _clientAssertionAuthentication.AuthenticateClientWithPrivateKeyJwtAsync(instruction); // ASSERT Assert.Null(result.Client); Assert.True(result.ErrorMessage == ErrorDescriptions.TheAudiencePassedInJwtIsNotCorrect); }
/// <summary> /// Check In <see cref="Models.Client"/> with extra data /// </summary> /// <param name="identifier">The <see cref="Models.Client.Identifier"/></param> /// <param name="type">The <see cref="ClientType.Name"/></param> /// <param name="extraData">Extra data you want stored with the <see cref="Models.CheckIn"/></param> /// <returns></returns> public static async Task CheckInClient <T>(string identifier, string type, T extraData) { if (!isInitialized) { throw new CaasException(CaasException.NOT_INITIALIZED); } var client = new Models.Client() { Identifier = identifier, ClientType = new ClientType() { Name = type } }; var checkIn = new Models.CheckIn <T>() { Client = client, ConvertedExtraData = extraData }; HttpResponseMessage result = await httpClient.PostAsync("/api/config/checkin", new StringContent(JsonConvert.SerializeObject(checkIn), System.Text.Encoding.UTF8, "application/json")).ConfigureAwait(false); if (result.IsSuccessStatusCode) { return; } else if (result.StatusCode == System.Net.HttpStatusCode.NoContent) { return; } else if (result.StatusCode == System.Net.HttpStatusCode.InternalServerError) { throw new CaasException(CaasException.SERVER_ERROR, result.ReasonPhrase); } else if (result.StatusCode == System.Net.HttpStatusCode.NotFound) { throw new CaasException(CaasException.SERVER_NOT_FOUND, result.ReasonPhrase); } else { throw new CaasException(CaasException.UNKNOWN_SERVER_RESPONSE, result.ReasonPhrase); } }
// GET: Client/Details/5 public ActionResult ClientDetails(int id = 0) { SqlConnection con = new SqlConnection(@"Data Source=(localdb)\MsSqlLocalDb;Initial Catalog=project;Integrated Security=True"); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = CommandType.Text; //details for admin or owner if (id != 0) { cmd.CommandText = "select * from Client where Cid=@Cid"; cmd.Parameters.AddWithValue("@Cid", id); } //detail for own else if (id == 0) { var s = Session["id"]; string username = Convert.ToString(Session["id"]); cmd.CommandText = "select * from Client where Email=@username"; cmd.Parameters.AddWithValue("@username", username); } SqlDataReader dr = cmd.ExecuteReader(); Models.Client o = new Models.Client(); if (dr.Read()) { o.Cid = Convert.ToInt32(dr["Cid"]); o.Email = Convert.ToString(dr["Email"]); o.Name = Convert.ToString(dr["Name"]); o.Phone = Convert.ToInt64(dr["Phone"]); o.Age = Convert.ToInt32(dr["Age"]); o.Gender = Convert.ToString(dr["Gender"]); o.Membership = Convert.ToBoolean(dr["Membership"]); } con.Close(); return(View(o)); }
private void txtRFC_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { dtClientes.Rows.Clear(); Models.Client clients = new Models.Client(); using (clients) { List <Models.Client> result = clients.getClientbyRFC(txtRFC.Text); if (result.Count > 0) { foreach (Models.Client item in result) { dtClientes.Rows.Add(item.Id, item.Name, item.RFC, item.Tel); } } } } }
private async void buttonAddNewClient_Click(object sender, System.EventArgs e) { if (!VerifyClintsValues(out var fio, out var telephone, out var address, await _clientsRepository.GetClients())) { return; } var client = new Models.Client() { FIO = fio, ContactNumber = telephone, Address = address }; NormalizeTables(); await _clientsRepository.CreateClient(client); await UpdateDataGridViewClients(); }
public ActionResult Index(LogPrUsTskComb combinedModel) { string userID = combinedModel.Login.UserID; string password = combinedModel.Login.Password; Login login = new Login(); if (login.testLogin(userID, password)) { combinedModel.Login.Message = "Authentification valide"; combinedModel.Login.AuthentificationValide = true; string matricule = login.getUserMatricule(userID, password); combinedModel.Login.Role = login.testUserRole(matricule); } else { combinedModel.Login.Message = "Authentification invalide"; return(View(combinedModel)); } User user = new User(); combinedModel.UsersList = user.getUsersFromDatabase(); Project project = new Project(); Models.Task task = new Models.Task(); Models.Client client = new Models.Client(); if (combinedModel.Login.Role == "Utilisateur") { combinedModel.ProjectsList = project.getProjectsByLogin(userID); combinedModel.TasksList = task.getAllTasksByLogin(userID); } else { combinedModel.ProjectsList = project.getProjectsFromDatabase(); combinedModel.TasksList = task.getAllTasksFromDatabase(); combinedModel.ClientsList = client.getClientsFromDatabase(); } return(View(combinedModel)); }
public void txtIdCliente_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (txtIdCliente.Text != "") { Models.Client clientes = new Models.Client(); using (clientes) { List <Models.Client> cliente = clientes.getClientbyId(Convert.ToInt32(txtIdCliente.Text)); if (cliente.Count > 0) { txtIdCliente.Text = cliente[0].Id.ToString(); txtCliente.Text = cliente[0].Name; } } } } }
public void GetAll_ListIsNotEmpty_ReturnsList() { var repository = Substitute.For <IClientRepository>(); Models.Client sweden = new Models.Client { Name = "Svedska", Id = Guid.NewGuid() }; List <Models.Client> allCountries = new List <Models.Client> { sweden }; repository.GetAll().Returns(new List <Models.Client> { sweden }); CollectionAssert.AreEqual(allCountries, (List <Models.Client>)(new ClientService(repository)).GetAll()); }
public ActionResult Create(IFormCollection collection) { try { var newClient = new Models.Client { Name = collection["Name"], LastName = collection["LastName"], PhoneNumber = Convert.ToInt32(collection["PhoneNumber"]), Description = collection["Description"] }; Singleton.Instance.ClientsList.Add(newClient); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task <Models.Client> GetByKeyAsync(int id) { CoreServiceDevReference.CoreServiceClient coreServiceClient = new CoreServiceDevReference.CoreServiceClient(); var clientRef = await coreServiceClient.GetClientByKeyAsync(id); var client = new Models.Client(); client.ClientKey = clientRef.ClientKey; client.ClientId = clientRef.ClientID; client.ClientName = clientRef.FirstName + " " + clientRef.LastName; client.DateOfBirth = (clientRef.DateOfBirth.HasValue) ? clientRef.DateOfBirth.Value.ToShortDateString() : "---"; client.DateCreated = clientRef.CreatedDateTime.ToShortDateString(); client.Gender = (clientRef.Gender.HasValue) ? clientRef.Gender.Value.ToString() : "---"; client.PrimaryEmail = clientRef.PrimaryEmail; client.GroupName = "---"; client.Age = GetAgeFromDOBCalculated(clientRef.DateOfBirth, clientRef.DateOfBirthComputed); return(client); }
public static DataAccessLayer.Entities.Client ModelClientToEntityClient(Models.Client clientModel) { DataAccessLayer.Entities.Client entityClient = new DataAccessLayer.Entities.Client { Id = clientModel.Id, FirstName = clientModel.FirstName, LastName = clientModel.LastName, Phone = clientModel.Phone, Email = clientModel.Email, ImagePath = clientModel.ImagePath, IsDeleted = clientModel.IsDeleted, BirthYear = clientModel.BirthYear, InsertedDate = clientModel.InsertedDate, IdentityNumber = clientModel.IdentityNumber, Sex = clientModel.Sex == "Male" ? false : true, Inserter = DataAccessLayer.Utils.EmployeeUtils.GetEmployeeByName(clientModel.InserterName), }; return(entityClient); }
public async Task FindClientByIdAsync_WhenClientExists_ExpectClientRetured() { // Arrange var testClient = new Models.Client { ClientId = Guid.NewGuid().ToString(), ClientName = Guid.NewGuid().ToString() }; var mapper = _hostContainer.Container.Resolve <IMapper>(); var repository = _hostContainer.Container.Resolve <IRepository <Entities.Client> >(); await repository.AddAsync(mapper.Map <Entities.Client>(testClient)).ConfigureAwait(false); // Assert var clientStore = _hostContainer.Container.Resolve <IClientStore>(); var client = await clientStore.FindClientByIdAsync(testClient.ClientId).ConfigureAwait(false); // Assert Assert.NotNull(client); }
public async Task <ActionResult <Models.Client> > Get(long id) { try { _client = await _iClient.GetClient(id); if (_client == null) { return(NotFound()); } return(_client); } catch (Exception) { //'500' means Internal Server Error return(StatusCode(500)); } }