public void FilterTest() { DataContext dataContext = new DataContext { Clients = new List <Client>() }; ClientRepository ClientRepository = new ClientRepository(dataContext); Client client = new Client { Id = -1, DateOfBirth = new DateTime(1990, 1, 1), Cart = new Cart(), Name = "John", LastName = "Doe" }; Client client2 = new Client { Id = -2, DateOfBirth = new DateTime(1991, 1, 1), Cart = new Cart(), Name = "Jack", LastName = "Sparrow" }; ClientRepository.Add(client); ClientRepository.Add(client2); List <Client> clients = ClientRepository.Get(c => c.DateOfBirth == new DateTime(1990, 1, 1)).ToList(); Assert.AreEqual(1, clients.Count()); }
public void Add_ClientRepository_ClientAdded() { // Arrange ClientEntity clientEntity = new ClientEntity(); clientEntity.Id = 1; clientEntity.Name = "Pirma"; clientEntity.IdCountry = 1; clientEntity.IsInEuropeanUnion = true; clientEntity.IsVATPayer = true; clientEntity.VATPercentage = 21; InvoiceController invoiceController = new InvoiceController(_clientRepository, _supplierRepository); // Act _clientRepository.Add(clientEntity); // Assert Assert.AreEqual(_clientRepository.GetBy(1).Name, "Pirma"); Assert.AreEqual(_clientRepository.GetBy(1).Id, 1); Assert.AreEqual(_clientRepository.GetBy(1).IdCountry, 1); Assert.AreEqual(_clientRepository.GetBy(1).IsInEuropeanUnion, true); Assert.AreEqual(_clientRepository.GetBy(1).IsVATPayer, true); Assert.AreEqual(_clientRepository.GetBy(1).VATPercentage, 21); Assert.AreEqual(_clientRepository.GetCount(), 1); }
public ActionResult Create([Bind(Include = "ClientId,FirstName,MiddleName,LastName,Gender,DateOfBirth,CreditRating,XCode,OccupationId,TelephoneNumber,Street1,Street2,City,ZipCode,Longitude,Latitude,Notes")] Client client) { if (ModelState.IsValid) { //db.Client.Add(client); ClientRepo.Add(client); ClientRepo.UnitOfWork.Commit(); /* * try * { * db.SaveChanges(); * } * catch (Exception) * { * * throw; * } */ return(RedirectToAction("Index")); } //ViewBag.OccupationId = new SelectList(db.Occupation, "OccupationId", "OccupationName", client.OccupationId); ViewBag.OccupationId = new SelectList(occuRepo.All(), "OccupationId", "OccupationName", client.OccupationId); return(View(client)); }
public bool Add(ClientDto model, out string id) { var mapper = MapperToModel(); var client = mapper.Map <ClientDto, Client>(model); return(_clientRepository.Add(client, out id)); }
public void ValidInfra() { IClientRepository Rep = new ClientRepository(); Client client = new Client(); List <string> phones = new List <string>(); client.SetBirth("15/03/1999"); client.SetCPF("04777951103"); client.SetEmail("*****@*****.**"); client.SetName("David de Melo"); phones.Add("062986182772"); phones.Add("062912345678"); client.SetPhone(phones); client.SetPostalCode("74000000"); client.SetRG("6473364"); Rep.Add(client); Assert.AreEqual(client, Rep.GetByCPF(client.CPF)); client.SetName("David Almeida"); Rep.Update(client); Assert.AreEqual(Rep.GetByCPF(client.CPF).Name, client.Name); Rep.Delete(client.CPF); Assert.ThrowsException <Exception>(() => Rep.GetByCPF(client.CPF)); }
public bool TryAddClient(Client client, Expression <Func <Client, bool> > searchExpression) { ResolveLocker(typeof(Client)).EnterWriteLock(); try { var searchedClient = GetEntity(searchExpression, ClientRepository); if (searchedClient != null) { return(false); } ClientRepository.Add(new EF.Client { FirstName = client.FirstName, LastName = client.LastName }); ClientRepository.Save(); return(true); } catch (Exception) { throw new ObjectAdditionException(client); } finally { ResolveLocker(typeof(Client)).ExitWriteLock(); } }
public void UpdateTest() { DataContext dataContext = new DataContext { Clients = new List <Client>() }; ClientRepository ClientRepository = new ClientRepository(dataContext); Client client = new Client { Id = -1, DateOfBirth = new DateTime(1990, 1, 1), Cart = new Cart(), Name = "John", LastName = "Doe" }; ClientRepository.Add(client); string newName = "Jack"; Client client2 = new Client { Id = -1, DateOfBirth = new DateTime(1990, 1, 1), Cart = new Cart(), Name = newName, LastName = "Doe" }; ClientRepository.Update(-1, client2); Assert.AreEqual(newName, ClientRepository.Get(-1).Name); }
public HttpResponseMessage Post(ClientViewModel model) { if (ModelState.IsValid) { ClientViewModel client; try { client = _repository.Add(model); } catch (NullReferenceException) { throw new HttpResponseException(new HttpResponseMessage { StatusCode = HttpStatusCode.NotFound, Content = new StringContent("Can't add undefined object") }); } var response = Request.CreateResponse <ClientViewModel>(HttpStatusCode.Created, client); string uri = Url.Link("DefaultApi", new { id = model.Id }); response.Headers.Location = new Uri(uri); return(response); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
void AddClientCommandExecute() { Client cl = new Client("1", "2", "3", "4"); _clientRepository.Add(cl); AllClients.Insert(AllClients.Count - 1, cl); }
public void Add(ClientView clientView) { using var clientRepository = new ClientRepository(); var client = _mapper.Map <Client>(clientView); clientRepository.Add(ref client); }
public ActionResult Create(FormCollection collection) { // TODO: Add insert logic here var v = new Client(); UpdateModel(v); repo.Add(v); return(RedirectToAction("Index")); }
public HttpResponseException Post(Client client) { if (client == null) { return(new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest))); } _repo.Add(client); return(new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Created))); }
public ActionResult Create(ClientVM clientobj) { if (ModelState.IsValid) { var client = Mapper.Map <ClientVM, Client>(clientobj); _clientRepo.Add(client); return Redirect } }
public WebSocketConnection(WebSocket socket, ControllerFactory controllerFactory, ClientRepository clientRepository, IBroadcastService broadcastService) { clientRepository.Add(this); _clientRepository = clientRepository; _socket = socket; _controllerFactory = controllerFactory; ConnectionId = Guid.NewGuid(); _broadcastService = broadcastService; }
public void Add(IUser newUser) { var entity = Mapper.Mapper.DTOtoEntity(newUser); using (var repository = new ClientRepository()) { repository.Add(entity); repository.SaveChanges(); } }
public ActionResult Create(ClientVM clientobj) { if (ModelState.IsValid) { var client = Mapper.Map <ClientVM, Client>(clientobj); _clientRepo.Add(client); return(RedirectToAction("Index")); } return(View(clientobj)); }
public void CreateNew(string name, DateTime activeUnil, int currentUserId) { Client newClient = new Client(); newClient.Name = name; newClient.ActiveUntil = activeUnil; newClient.ApiKey = SecurityHelper.GenerateApiKey(); newClient.UserId = currentUserId; _repository.Add(newClient); }
private void RegisterClient(NotifyClientAbstraction request, string userContextId, Notification notification) { foreach (var userId in request.UsersId) { var client = new Client(userId, userContextId); _clientRepository.Add(client); RegisterClientNotification(client.Id, notification.Id, userContextId); } }
public void RememberClientTest() { IRepository<Client> _clientRepository = new ClientRepository(); Program.ClearInformation(); Client client = new Client(2, "Petr Petrov"); _clientRepository.Add(client); Client actual = _clientRepository.GetItem(client.id); Assert.AreEqual(client.id, actual.id); Assert.AreEqual(client.name, actual.name); Program.ClearInformation(); }
private void createButton_Click(object sender, EventArgs e) { if (checkIsFilled(numeTextbox.Text, prenumeTextbox.Text, adresaTextbox.Text, localitateTextbox.Text, judetTextbox.Text, telefonTextbox.Text, emailTextbox.Text) && !phoneNumberIsAlreadyExists(telefonTextbox.Text)) { Client client = new Client(); client.Nume = numeTextbox.Text; client.Prenume = prenumeTextbox.Text; client.Adresa = adresaTextbox.Text; client.Localitate = localitateTextbox.Text; client.Judet = judetTextbox.Text; client.Telefon = telefonTextbox.Text; client.Email = emailTextbox.Text; clientRepository.Add(client); MessageBox.Show("Userul a fost inserat"); } else { MessageBox.Show("Nu sunt completate toate fieldurile sau numarul de telefon exista deja in baza de date"); } }
public void FilterByName_NameOfClientIsCorrectAndClientsWhoHaveTheNameThatContainsEnteredNameExist_ReturnsList() { ClientRepository repository = new ClientRepository(_validConnectionString); Client client1 = new Client() { Id = Guid.NewGuid(), Name = "Samsung", CountryId = id }; Client client2 = new Client() { Id = Guid.NewGuid(), Name = "Pandora", CountryId = id }; repository.Add(client1); repository.Add(client2); Assert.AreEqual(1, repository.FilterByName("ndora").Count()); }
public void FilterByName_NameOfClientIsEmpty_ReturnsList() { ClientRepository repository = new ClientRepository(_validConnectionString); Client client1 = new Client() { Id = Guid.NewGuid(), Name = "Samsung", CountryId = id }; Client client2 = new Client() { Id = Guid.NewGuid(), Name = "Pandora", CountryId = id }; repository.Add(client1); repository.Add(client2); Assert.AreEqual(2, repository.FilterByName("").Count()); }
public void CollectionInsertTest() { var customer = new Client {Name = "Customer-LazyLoad", Family = "CustomerA1"}; var ClientRepository = new ClientRepository(_unitOfWork); ClientRepository.Add(customer); var account1 = new Account {Client = customer, Balance = 10, OpendedDate = DateTime.Now}; var account2 = new Account {Client = customer, Balance = 100, OpendedDate = DateTime.Now}; customer.Accounts = new Collection<Account> {account1, account2}; _unitOfWork.Commit(); customer = ClientRepository.FindByID(customer.ClientID); Assert.AreEqual(2, customer.Accounts.Count); }
public void FilterByFirstLetterOfName_FirstLetterOfClientNameIsCorrectAndClientsWhoHaveEnteredLetterAsTheFirstLetterOfTheNameExist_ReturnsList() { ClientRepository repository = new ClientRepository(_validConnectionString); Client client1 = new Client() { Id = Guid.NewGuid(), Name = "Samsung", CountryId = id }; Client client2 = new Client() { Id = Guid.NewGuid(), Name = "Pandora", CountryId = id }; repository.Add(client1); repository.Add(client2); Assert.AreEqual(1, repository.FilterByFirstLetterOfName(char.Parse("p")).Count()); }
public ActionResult Create([Bind(Include = "ClientId,FirstName,MiddleName,LastName,Gender,DateOfBirth,CreditRating,XCode,OccupationId,TelephoneNumber,Street1,Street2,City,ZipCode,Longitude,Latitude,Notes,IdNumber")] Client client) { if (ModelState.IsValid) { repo.Add(client); repo.UnitOfWork.Commit(); return(RedirectToAction("Index")); } ViewBag.OccupationId = new SelectList(occuRepo.All(), "OccupationId", "OccupationName", client.OccupationId); return(View(client)); }
protected void BtnConfirmer_Click(object sender, EventArgs e) { ContactClient contactNouveauClient = new ContactClient(TxtNomCLient.Text, TxtMatrimoniale.Text, TxtTelephoneClient.Text, TxtEmailClient.Text, TxtAdressseClient.Text, TxtAdresse2Client.Text, TxtCpClient.Text, TxtVilleClient.Text); Client nouveauClient = new Client(); nouveauClient.ListeContactClient.Add(contactNouveauClient); nouveauClient.Name = contactNouveauClient.Nom; ClientRepository clientRepository = new ClientRepository(); clientRepository.Add(nouveauClient); Response.Redirect("NouveauDevis.aspx"); }
public void Clients_Repository_Add_ShouldBeOk() { //Action var orderRegistered = _repository.Add(_client); //Verify orderRegistered.Should().NotBeNull(); orderRegistered.Id.Should().NotBe(0); var expectedCustomer = _ctx.Clients.Find(orderRegistered.Id); expectedCustomer.Should().NotBeNull(); expectedCustomer.Should().Be(orderRegistered); }
public ActionResult AddClient(long companyId, string clientName) { Client client = new Client() { TenantID = companyId, ClientName = clientName }; ClientRepository clientRepository = new ClientRepository(companyId); clientRepository.Add(client); clientRepository.PersistChanges(); return(Content(JsonConvert.SerializeObject(client))); }
public void IsExistingClientTest() { Program.ClearInformation(); IRepository<Client> _clientRepository = new ClientRepository(); _clientRepository.Add(new Client(1, "Ivan Ivanov")); IEnumerable<Client> clientRepository = _clientRepository.GetItems(); Client client = new Client(2, "Petr Petrov"); bool expected = false; bool actual = Realtor.IsExistingClient(clientRepository, client.name); Assert.AreEqual(expected, actual); Program.ClearInformation(); }
public void Add(Client client) { using (var clients = new ClientRepository()) { try { clients.Add(client); } catch { throw; } } }
public void RememberClientTest() { IRepository <Client> _clientRepository = new ClientRepository(); Program.ClearInformation(); Client client = new Client(2, "Petr Petrov"); _clientRepository.Add(client); Client actual = _clientRepository.GetItem(client.id); Assert.AreEqual(client.id, actual.id); Assert.AreEqual(client.name, actual.name); Program.ClearInformation(); }
public async Task Should_Add_A_Clent() { var mockSet = new Mock <DbSet <Client> >(); var mockContext = new Mock <PetShopDbContext>(); mockContext.Setup(m => m.Clients).Returns(mockSet.Object); var repository = new ClientRepository(mockContext.Object); await repository.Add(new Client() { Name = "Lee" }); mockSet.Verify(m => m.Add(It.IsAny <Client>()), Times.Once()); mockContext.Verify(m => m.SaveChangesAsync(It.IsAny <CancellationToken>()), Times.Once()); }
/// <summary> /// Metoda sprawdza walidacje wartości pól dodaje nowy obiekt do bazy danych, czyści wartości pól oraz zamyka okno i odświeża widok Grida /// </summary> /// <param name="sender">Przycisk dodający zadnaie</param> /// <param name="e"></param> private void btnAccept_Click(object sender, EventArgs e) { if (AreFieldsNullOrEmpty()) { MessageBox.Show("Uzupełnij wszystkie pola!"); return; } var cr = new ClientRepository(); cr.Add(tbAddress.Text, tbEmail.Text, tbName.Text, tbPhoneNumber.Text, tbSurname.Text, tbComments.Text); ClearTextValue(); this.Close(); RefreshGrid(sender, e); }
public void ClientRepositoryTest() { ClientRepository repository = new ClientRepository(); Client expectedClient = new Client(repository.GetAll().Count() + 1, "clientsomeclient"); repository.Add(expectedClient); Client realClient = repository.GetItem(expectedClient.id); Assert.AreEqual(expectedClient, realClient); repository.Delete(expectedClient); realClient = repository.GetItem(expectedClient.id); Assert.AreEqual(null, realClient); }
public void ClientRepositoryTest() { ClientRepository repository = new ClientRepository(); Client expectedClient = new Client { name = "clientsomeclient" }; repository.Add(expectedClient); Client realClient = repository.GetAll().Last(); Assert.AreEqual(expectedClient, realClient); repository.Delete(realClient); realClient = repository.GetAll().Last(); Assert.AreNotEqual(expectedClient.name, realClient.name); }
public static void AutoFilling() { Product[] product = new Product[10]; Client[] client = new Client[10]; Manager[] manager = new Manager[10]; product[0] = new Product(1, "House", "Moskovskaya, 320", "for sale"); product[1] = new Product(2, "Office", "MOPRa, 30", "for sale"); product[2] = new Product(3, "House", "Belorusskaya, 10", "for sale"); product[3] = new Product(4, "Bar", "MOPRa, 3", "for sale"); product[4] = new Product(5, "House", "Leningradskaya, 35", "for sale"); product[5] = new Product(6, "Cafe", "Molodogvardeiskaya, 70", "for sale"); product[6] = new Product(7, "House", "Moskovskaya, 30", "for sale"); product[7] = new Product(8, "Club", "Zelenaya, 11", "for sale"); product[8] = new Product(9, "House", "Lugivaja, 11", "for sale"); product[9] = new Product(10, "Pizzeria", "Pionerskaya, 4", "for sale"); client[0] = new Client(1, "Fedor Dvinyatin"); client[1] = new Client(2, "Alexei Volkov"); client[2] = new Client(3, "Ivan Ivanov"); client[3] = new Client(4, "Petr Bojko"); client[4] = new Client(5, "Egor Valedinsky"); client[5] = new Client(6, "Alexander Evtuh"); client[6] = new Client(7, "Alexei Lohnitsky"); client[7] = new Client(8, "Mokin Alexander"); client[8] = new Client(9, "Pavlovets Sergey"); client[9] = new Client(10, "Igor Pujko"); manager[0] = new Manager(1, "Viktor Oniskevich"); manager[1] = new Manager(2, "Petr Glinskij"); manager[2] = new Manager(3, "Fedor Yakubuk"); manager[3] = new Manager(4, "Vasily Sapon"); manager[4] = new Manager(5, "Igor Ivanovskiy"); manager[5] = new Manager(6, "Alexander Dubrovsky"); manager[6] = new Manager(7, "Olga Golub"); manager[7] = new Manager(8, "Egor Pirozhkov"); manager[8] = new Manager(9, "Boris Zhukovich"); manager[9] = new Manager(10, "Igor Stepanchuk"); IRepository<Client> _clientRepository = new ClientRepository(); IRepository<Product> _productRepository = new ProductRepository(); IRepository<Manager> _managerRepository = new ManagerRepository(); IEnumerable<Client> clientRepository = _clientRepository.GetItems(); IEnumerable<Product> productRepository = _productRepository.GetItems(); IEnumerable<Manager> managerRepository = _managerRepository.GetItems(); foreach (var item in clientRepository) { _clientRepository.Remove(item); } foreach (var item in productRepository) { _productRepository.Remove(item); } foreach (var item in managerRepository) { _managerRepository.Remove(item); } for (int i = 0; i <= 9; i++) { _clientRepository.Add(client[i]); _productRepository.Add(product[i]); _managerRepository.Add(manager[i]); } }
public void InsertTest() { var customer = new Client {Name = "abc", Family = "abc"}; var ClientRepository = new ClientRepository(_unitOfWork); const string start = "a"; ClientRepository.Add(customer); _unitOfWork.Commit(); var insertedCustomer = ClientRepository.GetFirstCustomerStartWith(start); Assert.AreNotEqual(null, insertedCustomer); }
public void UnitOfWorkTest() { var customer = new Client {Name = "CustomerA1", Family = "CustomerA1"}; var ClientRepository = new ClientRepository(_unitOfWork); ClientRepository.Add(customer); var account1 = new Account {Client = customer, Balance = 0, OpendedDate = DateTime.Now}; var account2 = new Account {Client = customer, Balance = 100, OpendedDate = DateTime.Now}; var accountRepository = new AccountRepository(_unitOfWork); accountRepository.Add(account1); accountRepository.Add(account2); _unitOfWork.Commit(); var accountList = accountRepository.GetCustomerAccounts(customer.ClientID); Assert.AreEqual(2, accountList.Count); }
public static void FillDb() { using (var context = new BankDbContext()) { Console.WriteLine("ConnectionString\n" + context.Database.Connection.ConnectionString); Console.WriteLine("DataSource\n" + context.Database.Connection.DataSource); Console.WriteLine("ConnectionString\n" + context.Database.Connection.Database); // CLEARS ALL DATA !!! Console.WriteLine("ALL DATA WILL BE DELETED FROM DB NOW!!! ([ENTER] TO PROCEED)"); Console.ReadLine(); //if (!context.Database.Exists()) //{ context.Database.Delete(); context.Database.Create(); //} context.Database.Initialize(true);// Console.WriteLine("Db initialized"); Console.ReadLine(); context.Accounts.RemoveRange(context.Accounts); ///Console.WriteLine("I've successfully completed first db action!"); ///Console.ReadLine(); context.Clients.RemoveRange(context.Clients); context.Credits.RemoveRange(context.Credits); context.CreditTypes.RemoveRange(context.CreditTypes); context.Payments.RemoveRange(context.Payments); context.Requests.RemoveRange(context.Requests); //context.RequestStatuses.RemoveRange(context.RequestStatuses); context.Users.RemoveRange(context.Users); context.SaveChanges(); // CLEARS ALL DATA !!! //var statusRepo = new RequestStatusRepository(context); //var statusCreated = new RequestStatus { Status = "Created" }; //var statusConfirmedByOperator = new RequestStatus { Status = "statusConfirmedByOperator" }; //var statusConfirmedBySse = new RequestStatus { Status = "statusConfirmedBySecurityServiceEmployee" }; ////var statusConfirmed = new RequestStatus { Status = "ConfirmedBy" }; //var statusCreditProvided = new RequestStatus { Status = "statusCreditProvided" }; //var statusDenied = new RequestStatus { Status = "Denied" }; //statusRepo.Add(statusCreated, statusConfirmedByOperator, statusConfirmedByOperator, statusCreditProvided,statusDenied); // context.SaveChanges(); // var confirmedByOperatorStatusId = statusCreditProvided.RequestStatusId; // var createdStatusId = statusCreated.RequestStatusId; // var deinedStatusId = statusDenied.RequestStatusId; var creditShort = new CreditType { Name = "Easy Money", //Type = "" WTF IS TYPE????? TimeMonths = 12, PercentPerYear = 20.0m, Currency = "USD", FinePercent = 40.0m, MinAmount = 200, MaxAmount = 2000, IsAvailable = true }; var creditMedium = new CreditType { Name = "Not So Easy Money", //Type = "" WTF IS TYPE????? TimeMonths = 12 * 2, PercentPerYear = 25.0m, Currency = "USD", FinePercent = 50.0m, MinAmount = 200, MaxAmount = 5000, IsAvailable = true }; var creditLong = new CreditType { Name = "Still Money", //Type = "" WTF IS TYPE????? TimeMonths = 12 * 4, PercentPerYear = 30.0m, Currency = "USD", FinePercent = 60.0m, MinAmount = 200, MaxAmount = 5000, IsAvailable = true }; var creditTypeRepo = new CreditTypeRepository(context); creditTypeRepo.Add(creditShort, creditLong, creditMedium); context.SaveChanges(); var creditEasyId = creditShort.CreditTypeId; var creditMediumId = creditMedium.CreditTypeId; var creditLongId = creditLong.CreditTypeId; var admin = new User { Login = "******", Password = "******", Role = UserRole.Admin, IsActive = true }; var ss = new User // security service employee { Login = "******", Password = "******", Role = UserRole.SecurityServiceEmployee, IsActive = true }; var operator1 = new User // { Login = "******", Password = "******", Role = UserRole.Operator, IsActive = true }; var operator2 = new User // { Login = "******", Password = "******", Role = UserRole.Operator, IsActive = true }; var client1 = new User { Login = "******", Password = "******", Role = UserRole.Client }; var client2 = new User { Login = "******", Password = "******", Role = UserRole.Client }; var client3 = new User { Login = "******", Password = "******", Role = UserRole.Client }; var userRepo = new UserRepository(context); userRepo.Add(admin, ss, operator1, operator2, client1, client2, client3); context.SaveChanges(); var client1Id = client1.UserId; var client2Id = client2.UserId; var client3Id = client3.UserId; var client1Info = new Client { UserId = client1.UserId, Name = "Clientone", LastName = "Clientov", Patronymic = "Clientovich", Birthday = new DateTime(1990, 1, 1), Mobile = "+375441234567", Email = "*****@*****.**", PassportNo = "AB1234567", PassportIdentificationNo = "4123456B124PB7", PassportAuthority = "Ministry of internal affairs", PassportExpirationDate = DateTime.Now.AddYears(6), PlaceOfResidence = "Pushkina st.1 app.18", RegistrationAddress = "Pushkina st.1 app.18" }; var client2Info = new Client { UserId = client2.UserId, Name = "Clienttwo", LastName = "Clientov", Patronymic = "Clientovich", Birthday = new DateTime(1982, 2, 2), Mobile = "+375251234567", Email = "*****@*****.**", PassportNo = "AB1234123", PassportIdentificationNo = "4125552B124PB7", PassportAuthority = "Ministry of internal affairs", PassportExpirationDate = DateTime.Now.AddYears(1), PlaceOfResidence = "Pushkina st.2 app.7", RegistrationAddress = "Pushkina st.2 app.7" }; var client3Info = new Client { UserId = client3.UserId, Name = "Clientthree", LastName = "Clientov", Patronymic = "Clientovich", Birthday = new DateTime(1973, 3, 3), Mobile = "+375291234567", Email = "*****@*****.**", PassportNo = "AB1223331", PassportIdentificationNo = "4129332B124PB3", PassportAuthority = "Ministry of internal affairs", PassportExpirationDate = DateTime.Now.AddYears(6), PlaceOfResidence = "Pushkina st.3 app.24", RegistrationAddress = "Pushkina st.3 app.24" }; var clientRepo = new ClientRepository(context); clientRepo.Add(client1Info, client2Info, client3Info); context.SaveChanges(); var request1client1 = new Request { ClientId = client1Info.ClientId, //RequestStatusId = createdStatusId, Status = RequestStatus.Created, CreditTypeId = creditEasyId, AmountOfCredit = 1000, Salary = 500 }; var request2client1 = new Request { ClientId = client1Info.ClientId, //RequestStatusId = createdStatusId, Status = RequestStatus.Created, OperatorId = operator1.UserId, CreditTypeId = creditMediumId, AmountOfCredit = 1200, Salary = 500 }; var request3client1 = new Request { ClientId = client1Info.ClientId, //RequestStatusId = confirmedByOperatorStatusId, Status = RequestStatus.ConfirmedByOperator, OperatorId = operator1.UserId, CreditTypeId = creditLongId, AmountOfCredit = 1000, Salary = 500 }; var request4client1 = new Request { ClientId = client1Info.ClientId, Status = RequestStatus.ConfirmedByOperator, // createdStatusId, OperatorId = operator1.UserId, CreditTypeId = creditMediumId, AmountOfCredit = 1100, Salary = 500 }; var request5client1 = new Request { ClientId = client1Info.ClientId, //RequestStatusId = createdStatusId, Status = RequestStatus.CreditProvided, OperatorId = operator1.UserId, CreditTypeId = creditLongId, AmountOfCredit = 1300, Salary = 500 }; var request6client1 = new Request { ClientId = client1Info.ClientId, //RequestStatusId = confirmedByOperatorStatusId, Status = RequestStatus.CreditProvided, OperatorId = operator1.UserId, CreditTypeId = creditLongId, AmountOfCredit = 900, Salary = 500 }; var request7client1 = new Request { ClientId = client1Info.ClientId, Status = RequestStatus.ConfirmedBySecurityOfficer, // createdStatusId, OperatorId = operator1.UserId, CreditTypeId = creditLongId, AmountOfCredit = 800, Salary = 500 }; var request8client1 = new Request { ClientId = client1Info.ClientId, //RequestStatusId = confirmedByOperatorStatusId, Status = RequestStatus.CreditProvided, OperatorId = operator1.UserId, CreditTypeId = creditMediumId, AmountOfCredit = 900, Salary = 500 }; var requestRepo = new RequestRepository(context); requestRepo.Add( request1client1, request2client1, request3client1, request4client1, request5client1, request6client1, request7client1, request8client1); context.SaveChanges(); //var acc1 = new Account //Bank Account //{ // ClientId = null, // Balance = 40*1000*1000 //}; var bankAccount = new BankAccount //Bank Account { Balance = 40 * 1000 * 1000, Currency = "USD" }; context.BankAccount = bankAccount; context.SaveChanges(); var acc2 = new Account { ClientId = client1Info.ClientId, Balance = request2client1.AmountOfCredit }; var accountRepo = new AccountRepository(context); accountRepo.Add( /*acc1,*/ acc2); context.SaveChanges(); DateTime dt1 = DateTime.Now.AddDays(-(30 * 4 + 5)); var credit1Client1 = new Credit { AccountId = acc2.AccountId, CreditTypeId = creditLong.CreditTypeId, //ContractNo = 123123, //random RequestId = request5client1.RequestId, //AllreadyPaid = 0, AmountOfPaymentPerMonth = (request5client1.AmountOfCredit / creditLong.TimeMonths) * (1 + creditLong.PercentPerYear / 100 * creditLong.TimeMonths / 12), StartDate = dt1, IsRepaid = false, HasDelays = false, CountFineFromThisDate = dt1.AddDays(30),//DateTime.UtcNow.AddDays(30), //!!! hard-coded!!! AmountToCountFineFromForFirstDelayedMonth = (request5client1.AmountOfCredit / creditLong.TimeMonths) * (1 + creditLong.PercentPerYear / 100 * creditLong.TimeMonths / 12), PaidForFine = 0 }; DateTime dt2 = DateTime.UtcNow.AddDays(-(30 * 50 + 7)); var credit2Client1 = new Credit { AccountId = acc2.AccountId, CreditTypeId = creditLong.CreditTypeId, //ContractNo = 123123, //random RequestId = request6client1.RequestId, //AllreadyPaid = 0, AmountOfPaymentPerMonth = (request6client1.AmountOfCredit / creditLong.TimeMonths) * (1 + creditLong.PercentPerYear / 100 * creditLong.TimeMonths/12), StartDate = dt2, IsRepaid = true, HasDelays = true, CountFineFromThisDate = dt2.AddDays(30), //!!! hard-coded!!! AmountToCountFineFromForFirstDelayedMonth = (request6client1.AmountOfCredit / creditLong.TimeMonths) * (1 + creditLong.PercentPerYear / 100 * creditLong.TimeMonths / 12), PaidForFine = 0 }; var credit3Client1 = new Credit { AccountId = acc2.AccountId, CreditTypeId = creditMedium.CreditTypeId, //ContractNo = 123123, //random RequestId = request8client1.RequestId, //AllreadyPaid = 0, AmountOfPaymentPerMonth = (request8client1.AmountOfCredit / creditMedium.TimeMonths) * (1 + creditMedium.PercentPerYear / 100 * creditMedium.TimeMonths / 12), StartDate = DateTime.Now, IsRepaid = false, HasDelays = true, CountFineFromThisDate = DateTime.Now.AddDays(30), //!!! hard-coded!!! AmountToCountFineFromForFirstDelayedMonth = (request8client1.AmountOfCredit / creditMedium.TimeMonths) * (1 + creditMedium.PercentPerYear / 100 * creditMedium.TimeMonths / 12), PaidForFine = 0 }; request5client1.Credit = credit1Client1; // IMPORTANT do this for 1-1 relationship (exception otherwise) request6client1.Credit = credit2Client1; // IMPORTANT do this for 1-1 relationship (exception otherwise) request8client1.Credit = credit3Client1; // IMPORTANT do this for 1-1 relationship (exception otherwise) var creditRepo = new CreditRepository(context); creditRepo.Add(credit1Client1, credit2Client1, credit3Client1); context.SaveChanges(); /* var payment = new Payment { OperatorId = operator1.UserId, CreditId = credit1Client1.CreditId, //ContractNo = credit1Client1.ContractNo, Amount = 75, Date = credit1Client1.StartDate.AddDays(15) }; //var credit var payRepo = new PaymentRepository(context); payRepo.Add(payment); */ var test = context.BankAccount; //context.RequestStatuses.Where(x => x.Status.Contains("Created")).FirstOrDefault(); //context.RequestStatuses.Add(new RequestStatus { Status = "Created" }); context.SaveChanges(); } }