public Client AddClient(Client client) { return(client != null && //если данные пришли client.Id != null && client.SubNetwork != null && ClientChecker.IsValidClientId(repo, client.Id) && //и id является валидным ClientChecker.IsValidIPAddress(client.SubNetwork) ? //и адрес подсети валидный repo.AddClient(client) : //то возвращаем добавленного клиента null); // иначе передаем на клиент null }
public async Task CanGetAll() { RepoUtil.Reset(_repo); await _repo.AddClient(ObjectMother.CreateClientDocument("id1")); await _repo.AddClient(ObjectMother.CreateClientDocument("id2")); await _repo.AddClient(ObjectMother.CreateClientDocument("id3")); var result = await _repo.GetAllClients(); Assert.AreEqual(3, result.Count()); }
public void AddClient() { Client client = new Client() { FirstName = "John", LastName = "Smith" }; repository.AddClient(client); Client fetchedClient = repository.GetClientByCredentials(client.FirstName, client.LastName); Assert.AreEqual(client.FirstName, fetchedClient.FirstName); Assert.AreEqual(client.LastName, fetchedClient.LastName); Assert.IsNotNull(fetchedClient); }
public void WhenClientAdded_AddClient_ItShouldAddSuccessfully() { Client testClient = CreateTestClientEntity(); ClientRepository testClientRepository = CreateTestClientRepository(); testClientRepository.AddClient(testClient); CreateTestEntities().Clients.Count().Should().BeGreaterOrEqualTo(0); }
public static int AddClient(Client client) { if (validate(client)) { return(ClientRepository.AddClient(client)); } return(-1); }
/// <summary> /// Adds Client object to database. /// </summary> /// <param name="client"></param> /// <returns>True if user is valid and successfully added to database, otherwise returns false.</returns> public bool AddClient(Client client) { if (client == null) { return(false); } clientRepo.AddClient(client); return(true); }
public bool AddClient(ClientModel model) { if (model == null) { return(false); } clientRepository.AddClient(MapModelDetails(model)); return(true); }
public IActionResult AddClient(AddClientViewModel addClientViewModel) { var result = _clientRepository.AddClient(addClientViewModel); if (result == Guid.Empty) { return(BadRequest("Email invalid")); } return(Ok(result)); }
private void FirstStart() { ModelContainer cont = new ModelContainer(); BranchRepository branchRepository = new BranchRepository(cont); CategoryRepository categoryRepository = new CategoryRepository(cont); CompanyOwnerRepository companyOwnerRepository = new CompanyOwnerRepository(cont); PersonRepository personRepository = new PersonRepository(cont); PositionRepository positionRepository = new PositionRepository(cont); RoomRepository roomRepository = new RoomRepository(cont); TableRepository tableRepository = new TableRepository(cont); ClientRepository clientRepository = new ClientRepository(cont); if (positionRepository.Positions().Count() == 0) { positionRepository.AddPosition("Суперпользователь", true, true, true, true, true, true); } CompanyOwner co = new CompanyOwner(); if (personRepository.Persones().Count() == 0) { co = companyOwnerRepository.AddCompanyOwner("Суперпользователь", "", "", "", "", "super", "super".GetHashCode().ToString(), "", "", "", positionRepository.GetPositionByName("Суперпользователь")); } Branch b = new Branch(); if (branchRepository.Branches().Count() == 0) { b = branchRepository.AddBranch("", "", DateTime.Now, DateTime.Now, "", "", "", "", "", co, null); } Room r = new Room(); if (roomRepository.Rooms().Count() == 0) { r = roomRepository.AddRoom("", b); } if (categoryRepository.Categotyes().Count() == 0) { categoryRepository.AddCategory(""); } if (tableRepository.Tables().Count() == 0) { tableRepository.AddTable(1, "", r); } if (clientRepository.Clients().Count() == 0) { clientRepository.AddClient("Клиент", "", "", "", "", "", "", "", "", "", "", ""); } }
public async Task <IHttpActionResult> AddClient([FromBody] ClientModel clientModel) { if (ModelState.IsValid) { return(Ok(await repository.AddClient(clientModel, rhNetContext))); } else { return(BadRequest(ModelState)); } }
/// <summary> /// Validating insertion of new Client record. Using internal method Validate /// </summary> /// <param name="client">Client object to validate</param> /// <returns>Return -1 if validation is fault, otherwise return number of rows affected</returns> public static int AddClient(Client client) { if (Validate(client)) { return(ClientRepository.AddClient(client)); } else { return(-VALIDATION); } }
public static void ConfigureClients(IEnumerable<Client> clients, DocumentDbServiceOptions options) { ClientRepository clientRepository = new ClientRepository(options.ToConnectionSettings()); var allClients = clientRepository.GetAllClients().Result; if (!allClients.Any()) { foreach (var c in clients) { clientRepository.AddClient(c.ToDocument()).Wait(); } } }
public async Task <ActionResult <ClientModel> > AddClient([FromServices] RhNetContext rhNetContext, [FromBody] ClientModel clientModel) { if (ModelState.IsValid) { ClientRepository repository = new ClientRepository(); return(await repository.AddClient(clientModel, rhNetContext)); } else { return(BadRequest(ModelState)); } }
public static int AddClient(Client client) { editMode = false; if (validate(client)) { return(ClientRepository.AddClient(client)); } else { return(-1); } }
public bool AddClient(Client client) { if (!IsClientInDataBase(client)) { if (ClientRepository.AddClient(client)) { Clients.Add(client); return(true); } } return(false); }
public static void ConfigureClients(IEnumerable <Client> clients, DocumentDbServiceOptions options) { ClientRepository clientRepository = new ClientRepository(options.CollectionNameResolver, options.ToConnectionSettings()); var allClients = clientRepository.GetAllClients().Result; if (!allClients.Any()) { foreach (var c in clients) { clientRepository.AddClient(c.ToDocument()).Wait(); } } }
public void ClientRepository_AddClient_Success() { //Arrange DataBaseContext db = new DataBaseContext(); IClientRepository clientRepo = new ClientRepository(db); Client newClient = new Client("Corporate"); //Act clientRepo.AddClient(newClient); Client addedClient = clientRepo.GetClientByName("Corporate"); //Assert Assert.IsNotNull(addedClient); }
public string AddClient(Client client) { if (!client.IsValid()) { return("Invalid data"); } var repo = new ClientRepository(); repo.AddClient(client); EmailServices.Send("*****@*****.**", client.Email, "Welcome", "Congratulations!!!"); return("Client ok"); }
public string AddClient(Client client) { if (!client.Valid()) { return("invalid data"); } var repo = new ClientRepository(); repo.AddClient(client); EmailService.Send("*****@*****.**", client.Email.EmailAddress, "Welcome.", "Congrats! You are registered."); return("successfully registered client"); }
public string AdicionarCliente(Client client) { if (!client.IsValid()) { return("Invalid Data"); } var repo = new ClientRepository(); repo.AddClient(client); EmailServices.Enviar("*****@*****.**", client.Email, "Welcome!", "Congratulations, you successfully joined in our platform!"); return("Client successfully registered"); }
/// <summary> /// Validates and adds a client to the database /// </summary> /// <param name="client">the client to add</param> /// <returns>SQL result of number of rows affected</returns> public static int AddClient(Client client) { //if(existingClientCode(client.ClientCode)) //{ // bool existing = true; //} if (validate(client)) { return(ClientRepository.AddClient(client)); } else { return(0); } }
public void AddClient(string name, string surname, int age) { if (!String.IsNullOrWhiteSpace(name) || !String.IsNullOrWhiteSpace(surname) || age != 0) { try { Client newClient = new Client(name, surname, age); repo.AddClient(newClient); Thread newFlow = new Thread(GetClients); newFlow.Start(); } catch (Exception e) { Console.WriteLine(e.Message); } } else { Console.WriteLine("Не все данные переданны! Пользователь не создастся!"); Console.WriteLine("Введите имя, фамилию, возраст"); } }
public void AddingNotUniqueId() { //добавим клиента в базу данных, затем получим его по id //и попробуем добавить другого пользователя с таким же id Client addedClient = new Client { Id = "newId2", SubNetwork = "222.222.222.222/20" }; repo.AddClient(addedClient); Client client = repo.GetClientById(addedClient.Id); try { Assert.That(ClientChecker.IsValidClientId(repo, client.Id), Is.EqualTo(false)); } finally { repo.Delete(client.Id); } }
private void SignUserButton_Click(object sender, EventArgs e) { // Create object of type ClientRepository ClientRepository client = new ClientRepository(); // Create Data base context var context = new CashierSystemEntities(); /****************************************************************************************** ** Get field values ** ******************************************************************************************/ // Get values of first name field var FirstNameClientField = SignUserFirstNameField.Text.ToString(); // Get values of Last name field var LastNameClientField = SignUserLastNameField.Text.ToString(); // Get values of Egn field var EgnClientEgnField = SignUserEgnField.Text.ToString(); /****************************************************************************************** ** Processing EGN ** ******************************************************************************************/ // Cast from string to int int EgnInt = int.Parse(EgnClientEgnField); var EgnCheck = context.Client.FirstOrDefault(egn => egn.client_egn == EgnInt); /****************************************************************************************** ** Get from the model generated client number ** ******************************************************************************************/ /****************************************************************************************** ** Interact with DB ** ******************************************************************************************/ // Check if there is empty field. if (FirstNameClientField.Length == 0 || LastNameClientField.Length == 0 || EgnClientEgnField.Length == 0) { // Thie message shows when fields are empty MessageBox.Show("Не сте въвели някое от поле !"); } else if (EgnCheck != null) { // This message shows when there is Client with such EGN. MessageBox.Show("Не може да има човек със същото ЕГН !"); } else { client.AddClient( new Client { // Record first name in DB client_first_name = FirstNameClientField, //Record Last name in DB client_last_name = LastNameClientField, // Record Egn in DB client_egn = EgnInt }); var ClientNumber = context.Client.FirstOrDefault(c => c.client_egn == EgnInt).client_serial_number; //Clear all fields SignUserFirstNameField.Text = ""; SignUserLastNameField.Text = ""; SignUserEgnField.Text = ""; GenClientNSignUser.Text = ClientNumber.ToString(); MessageBox.Show("Успешен запис !"); } }
public static void UpdateRepositories(TestContext context) { // Ako repozitoriji nisu napunjeni if (clientDebtRepository.GetAllClientDebts().Count == 0) { Exercise exercise1 = new Exercise("Čučnjevi", FitnessLevel.Beginner, "Opis čučnjeva"); Exercise exercise2 = new Exercise("Sklekovi", FitnessLevel.Intermediate, "Opis sklekova"); Exercise exercise3 = new Exercise("Plank", FitnessLevel.Beginner, "Opis planka"); Exercise exercise4 = new Exercise("Ruski čučnjevi", FitnessLevel.Advanced, "Opis ruskih čučnjeva"); Exercise exercise5 = new Exercise("Bočni plank", FitnessLevel.Intermediate, "Opis bočnog planka"); Exercise exercise6 = new Exercise("Podizanja trupa", FitnessLevel.Intermediate, "Opis podizanja trupa"); exerciseRepository.AddExercise(exercise1); exerciseRepository.AddExercise(exercise2); exerciseRepository.AddExercise(exercise3); exerciseRepository.AddExercise(exercise4); exerciseRepository.AddExercise(exercise5); exerciseRepository.AddExercise(exercise6); Training training1 = new Training("Trening funkcionalne snage", FitnessLevel.Beginner, new List <Exercise> { exercise1, exercise2, exercise3 }); Training training2 = new Training("Napredni trening funkcionalne snage", FitnessLevel.Advanced, new List <Exercise> { exercise1, exercise2, exercise3, exercise4, exercise5, exercise6 }); trainingRepository.AddTraining(training1); trainingRepository.AddTraining(training2); TrainingPeriod trainingPeriod1 = new TrainingPeriod(DayOfWeek.Monday, new TimeSpan(17, 0, 0), new TimeSpan(18, 0, 0)); TrainingPeriod trainingPeriod2 = new TrainingPeriod(DayOfWeek.Tuesday, new TimeSpan(17, 0, 0), new TimeSpan(18, 0, 0)); TrainingPeriod trainingPeriod3 = new TrainingPeriod(DayOfWeek.Wednesday, new TimeSpan(17, 0, 0), new TimeSpan(18, 0, 0)); TrainingPeriod trainingPeriod4 = new TrainingPeriod(DayOfWeek.Thursday, new TimeSpan(17, 0, 0), new TimeSpan(18, 0, 0)); TrainingPeriod trainingPeriod5 = new TrainingPeriod(DayOfWeek.Friday, new TimeSpan(17, 0, 0), new TimeSpan(18, 0, 0)); TrainingPeriod trainingPeriod6 = new TrainingPeriod(DayOfWeek.Saturday, new TimeSpan(17, 0, 0), new TimeSpan(18, 0, 0)); TrainingPeriod trainingPeriod7 = new TrainingPeriod(DayOfWeek.Sunday, new TimeSpan(17, 0, 0), new TimeSpan(18, 0, 0)); trainingPeriodRepository.AddTrainingPeriod(trainingPeriod1); trainingPeriodRepository.AddTrainingPeriod(trainingPeriod2); trainingPeriodRepository.AddTrainingPeriod(trainingPeriod3); trainingPeriodRepository.AddTrainingPeriod(trainingPeriod4); trainingPeriodRepository.AddTrainingPeriod(trainingPeriod5); trainingPeriodRepository.AddTrainingPeriod(trainingPeriod6); trainingPeriodRepository.AddTrainingPeriod(trainingPeriod7); TrainingGroup trainingGroup1 = new TrainingGroup("Početnička grupa", training1, new List <TrainingPeriod> { trainingPeriod2, trainingPeriod4 }, 200.00M); TrainingGroup trainingGroup2 = new TrainingGroup("Napredna grupa", training2, new List <TrainingPeriod> { trainingPeriod1, trainingPeriod3, trainingPeriod5 }, 300.00M); trainingGroupRepository.AddTrainingGroup(trainingGroup1); trainingGroupRepository.AddTrainingGroup(trainingGroup2); Client client1 = new Client("12938549201", "Ivana", "Marković", new DateTime(1981, 1, 8), "0912728274", new DateTime(2020, 2, 10), FitnessLevel.Beginner, "Ima problema s koljenima", new List <TrainingGroup> { trainingGroup1 }); Client client2 = new Client("52932999221", "Đorđe", "Ivanović", new DateTime(1991, 5, 20), "0981827364", new DateTime(2020, 9, 5), FitnessLevel.Advanced, "", new List <TrainingGroup> { trainingGroup1, trainingGroup2 }); Client client3 = new Client("29375948378", "Josip", "Cvitković", new DateTime(1995, 10, 15), "0913819204", new DateTime(2020, 10, 10), FitnessLevel.Advanced, "", new List <TrainingGroup> { trainingGroup2 }); Client client4 = new Client("10382960594", "Sara", "Praputak", new DateTime(1998, 4, 25), "0998278477", new DateTime(2021, 1, 11), FitnessLevel.Beginner, "Ima problema s leđima", new List <TrainingGroup> { trainingGroup1 }); Client client5 = new Client("10283953829", "Ivona", "Malenica", new DateTime(1997, 12, 12), "0919287782", new DateTime(2021, 1, 15), FitnessLevel.Beginner, "", new List <TrainingGroup> { trainingGroup1 }); clientRepository.AddClient(client1); clientRepository.AddClient(client2); clientRepository.AddClient(client3); clientRepository.AddClient(client4); clientRepository.AddClient(client5); ClientDebt clientDebt1 = new ClientDebt(client1, 200.00M, "Članarina za studeni 2020 (Početna grupa)"); ClientDebt clientDebt2 = new ClientDebt(client1, 200.00M, "Članarina za prosinac 2020 (Početna grupa)"); ClientDebt clientDebt3 = new ClientDebt(client2, 200.00M, "Članarina za prosinac 2020 (Početna grupa)"); ClientDebt clientDebt4 = new ClientDebt(client2, 300.00M, "Članarina za prosinac 2020 (Napredna grupa)"); ClientDebt clientDebt5 = new ClientDebt(client3, 300.00M, "Članarina za prosinac 2020 (Napredna grupa)"); ClientDebt clientDebt6 = new ClientDebt(client4, 200.00M, "Članarina za prosinac 2020 (Početna grupa)"); ClientDebt clientDebt7 = new ClientDebt(client5, 200.00M, "Članarina za prosinac 2020 (Početna grupa)"); clientDebtRepository.AddClientDebt(clientDebt1); clientDebtRepository.AddClientDebt(clientDebt2); clientDebtRepository.AddClientDebt(clientDebt3); clientDebtRepository.AddClientDebt(clientDebt4); clientDebtRepository.AddClientDebt(clientDebt5); clientDebtRepository.AddClientDebt(clientDebt6); clientDebtRepository.AddClientDebt(clientDebt7); } }
public IActionResult ClientAdded(string name, int hourlyRate, int billingDay) { clientRepository.AddClient(name, 0, hourlyRate, billingDay, false); return(RedirectToAction("Index")); }
public void AddClient(Client client) { clientRepository.AddClient(client); }
private static void PrepareBasicData() { var internetClientRepository = new InternetClientRepository(); var clientRepository = new ClientRepository(); var objectRepository = new ObjectRepository(); var orderRepository = new OrderRepository(); var obj = new Object(); obj.Description = "Kabel usb"; obj.Price = 2; obj.InStock = 1000; objectRepository.AddObject(obj); obj = new Object(); obj.Description = "Pilot"; obj.Price = 10; obj.InStock = 100; objectRepository.AddObject(obj); obj = new Object(); obj.Description = "Tv 40 cali"; obj.Price = 1000; obj.InStock = 15; objectRepository.AddObject(obj); obj = new Object(); obj.Description = "Karta graficzna gtx 1060TI"; obj.Price = 800; obj.InStock = 8; objectRepository.AddObject(obj); obj = new Object(); obj.Description = "Macbook pro 16 cali"; obj.Price = 4500; obj.InStock = 3; objectRepository.AddObject(obj); obj = new Object(); obj.Description = "Mointor Dell 23,8 cala"; obj.Price = 550; obj.InStock = 5; objectRepository.AddObject(obj); obj = new Object(); obj.Description = "Słuchawki nauszne sony"; obj.Price = 139; obj.InStock = 12; objectRepository.AddObject(obj); obj = new Object(); obj.Description = "Bateria AAA"; obj.Price = 1; obj.InStock = 250; objectRepository.AddObject(obj); var client = new Client(); client.Address = "Wieszczycka 2"; client.Name = "Zbyszek"; clientRepository.AddClient(client); client = new Client(); client.Address = "Pokoleń 2"; client.Name = "Andrzej"; clientRepository.AddClient(client); client = new Client(); client.Address = "Jelitkowska 2"; client.Name = "Krzysztof"; clientRepository.AddClient(client); client = new Client(); client.Address = "Cietrzewia"; client.Name = "Maciej W"; clientRepository.AddClient(client); client = new Client(); client.Address = "Pokoleń 13"; client.Name = "Adrian"; clientRepository.AddClient(client); client = new Client(); client.Address = "Grunwaldzka 123/3A"; client.Name = "Dominik M"; clientRepository.AddClient(client); var internetClient = new InternetClient(); internetClient.IpAddress = "123.231.23.2"; internetClient.Name = "Wiesław a"; internetClient.Address = "Częstochowska 1"; internetClientRepository.AddInternetClient(internetClient); internetClient = new InternetClient(); internetClient.IpAddress = "123.222.24.2"; internetClient.Name = "katarzyna w"; internetClient.Address = "Głuszcza 12"; internetClientRepository.AddInternetClient(internetClient); internetClient = new InternetClient(); internetClient.IpAddress = "234.222.21.2"; internetClient.Name = "Martyna K"; internetClient.Address = "Jana Pawła II 23/2"; internetClientRepository.AddInternetClient(internetClient); internetClient = new InternetClient(); internetClient.IpAddress = "111.222.11.12"; internetClient.Name = "katarzyna w"; internetClient.Address = "Głuszcza 12"; internetClientRepository.AddInternetClient(internetClient); internetClient = new InternetClient(); internetClient.IpAddress = "142.122.24.11"; internetClient.Name = "Tomasz K"; internetClient.Address = "Do studzienki"; internetClientRepository.AddInternetClient(internetClient); internetClient = new InternetClient(); internetClient.IpAddress = "102.100.10.10"; internetClient.Name = "Zuzanna K"; internetClient.Address = "Marynarki polskiej 11/12"; internetClientRepository.AddInternetClient(internetClient); var objects = objectRepository.GetAllObjects(); var clients = ClientService.GetAllClients(); Random rnd = new Random(); for (int i = 0; i < 20; i++) { var order = new Order(); order.ClientId = clients.OrderBy(x => Guid.NewGuid()).ToList()[0].Id; int numberOfProducts = rnd.Next(1, 6); for (int j = 0; j < numberOfProducts; j++) { var orderObj = new OrderObject(); orderObj.ObjectId = objects.OrderBy(x => Guid.NewGuid()).ToList()[0].Id; orderObj.Amount = rnd.Next(1, objectRepository.GetObject(orderObj.ObjectId).InStock / 2); order.Objects.Add(orderObj); } orderRepository.AddOrder(order); } }
private void AddClient(AccountRegisterViewModel viewModel) => _clientRepository.AddClient(viewModel);
public void AddClient(Person person) { _clientRepository.AddClient(person); }
public ClientConfirmationDto AddClient(ClientCreationDto client) { var addedClient = ClientRepository.AddClient(new Client(Guid.NewGuid(), client.CountryId, client.Name, client.Address, client.City, client.Postal, client.Country)); return(Mapper.Map <ClientConfirmationDto>(addedClient)); }