public void CreditCardAuthorizeSuccessfulTest() { var client = new NaturalPerson("Jan Kowalski", "11312737254"); var card = new CreditCard("1234567890", client, true, 1250.12m); Assert.AreEqual(card.Authorize(1500), BankActionResult.SUCCESS); }
//[Authorize(Roles = "admin")] public async Task <IActionResult> PutNaturalPerson(int id, NaturalPerson naturalPerson) { if (id != naturalPerson.id) { return(BadRequest()); } _context.Entry(naturalPerson).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NaturalPersonExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void CreditCardAuthorizeRejectedTest() { var client = new NaturalPerson("Jan Kowalski", "11312737254"); var card = new CreditCard("1234567890", client, true, 1250.12m); Assert.AreEqual(card.Authorize(-3500), BankActionResult.REJECTED_INSUFFICIENT_ACCOUNT_BALANCE); }
static void Main(string[] args) { #region SRP Supplier supplier = new Supplier(); supplier.ChangeName("Paulo Steinberg"); ISupplierRepository repository = new SupplierRepository(); repository.Save(supplier); #endregion #region OCP Person person = new Person("Paulo"); person.ChangeName("Paulo Steinberg"); NaturalPerson nPerson = new NaturalPerson("Paulo Steinberg", "123.123.123.12"); #endregion #region LSP Car car = new Car(); car.TurnOn(); car.SpeedUp(); #endregion #region ISP Invoice invoice = new Invoice(); invoice.CreateInvoice(); #endregion #region DIP var DIPrepository = new CustomerRepository(); var customerService = new CustomerService(DIPrepository); #endregion }
public bool UpdateClient(int id, [FromBody] NaturalPerson inst) { if (id == inst.PersonId) { var tmp = from dc in nc.NaturalPersons where dc.PersonId == inst.PersonId select dc; var t = tmp.Count() > 0 ? tmp.First() : null; if (t != null) { t.PersonAge = inst.PersonAge; t.PersonFullName = inst.PersonFullName; t.BillsOfPerson = inst.BillsOfPerson; nc.SaveChanges(); return(true); } else { return(false); } } else { return(false); } }
public void Update(UpdateCustomerViewModel model) { Customer customer = uow.RepostiryCustomer.Find(c => c.CustomerId == model.CustomerId); if (customer is null) { throw new CustomerNullException("Customer doesn't exist! "); } if (model.Type == CustomerType.NaturalPerson) { NaturalPerson np = customer as NaturalPerson; np.FirstName = model.FirstName; np.LastName = model.LastName; np.PhoneNumber = model.PhoneNumber; np.Address.CityName = model.CityName; np.Address.StreetName = model.StreetName; np.Address.PTT = model.PTT; np.Address.StreetNumber = model.StreetNumber; } else { LegalEntity lg = customer as LegalEntity; lg.CompanyName = model.CompanyName; lg.TIN = model.TIN; lg.PhoneNumber = model.PhoneNumber; lg.Address.CityName = model.CityName; lg.Address.StreetName = model.StreetName; lg.Address.PTT = model.PTT; lg.Address.StreetNumber = model.StreetNumber; } uow.Commit(); }
//[AllowAnonymous] public async Task <ActionResult <NaturalPerson> > PostNaturalPerson(NaturalPerson naturalPerson) { _context.natural_person.Add(naturalPerson); await _context.SaveChangesAsync(); return(CreatedAtAction("GetNaturalPerson", new { id = naturalPerson.id }, naturalPerson)); }
private void readAllNaturalPersonsFromDatabase(SQLiteCommand sqlite_cmd, out SQLiteDataReader sqlite_datareader) { sqlite_datareader = sqlite_cmd.ExecuteReader(); try { sqlite_cmd.CommandText = "SELECT * FROM NaturalPersons"; while (sqlite_datareader.Read()) { NaturalPerson newPerson = new NaturalPerson(int.Parse(sqlite_datareader["Id"].ToString()), sqlite_datareader["Name"].ToString(), sqlite_datareader["Surname"].ToString(), long.Parse(sqlite_datareader["IdentificationCode"].ToString()), int.Parse(sqlite_datareader["PassportCode"].ToString())); ((App)Application.Current).NaturalPersons.Add(newPerson); } if (((App)Application.Current).NaturalPersons.Count > 0) { NaturalPerson.MaxId = ((App)Application.Current).NaturalPersons[((App)Application.Current).NaturalPersons.Count - 1].Id + 1; } } catch (Exception e) { Logger.Log.Info(e.ToString()); } }
public IActionResult Update(long id, [FromBody] NaturalPerson item) { if (item == null || item.Id != id) { return(BadRequest()); } var person = _context.NaturalPersons.FirstOrDefault(t => t.Id == id); if (person == null) { return(NotFound()); } person.Surname = item.Surname; person.Name = item.Name; person.Patronymic = item.Patronymic; person.Sex = item.Sex; person.DateOfBirth = item.DateOfBirth; person.IdentityDocuments = item.IdentityDocuments; _context.NaturalPersons.Update(person); _context.SaveChanges(); return(new NoContentResult()); }
public void Add_Valid_IdDocument() { var person = new NaturalPerson( "Jorge Amado", "719.032.860-26", DateTime.Today, NaturalPerson.GenderType.Male, null); Assert.True(person.IdDocument == "719.032.860-26"); }
public void Add_Valid_Person_Without_Address() { var person = new NaturalPerson( "Jorge Amado", "719.032.860-26", DateTime.Today, NaturalPerson.GenderType.Male, null); Assert.True(person.Name == "Jorge Amado"); }
public void CreditCardDebitAfterTransactionTest() { var client = new NaturalPerson("Jan Kowalski", "11312737254"); var card = new CreditCard("1234567890", client, true, 1250.12m); card.MakeTransaction(-1400m); Assert.AreEqual(-149.88m, card.Balance); }
public void ShowData(NaturalPerson client) { txtFullName.text = client.FullName; txtId.text = "Id: " + client.iD; txtOccupation.text = "Occupation: " + client.Occupation; txtAddress.text = "Address: " + client.Address; txtContactNumber.text = "Phone: " + client.ContactNum; }
public void CreditCardSuccessfulTransactionTest() { var client = new NaturalPerson("Jan Kowalski", "11312737254"); var card = new CreditCard("1234567890", client, true, 1250.12m); card.MakeTransaction(1200m); Assert.AreEqual(card.Balance, 2450.12m); }
public void DebitCardsAreEqualTest() { var client = new NaturalPerson("Jan Kowalski", "11312737254"); var card = new DebitCard("1234567890", client, true, 1250.12m); var card2 = new DebitCard("1234567890", client, true, 1250.12m); Assert.AreEqual(card, card2); }
public void ATMCardsAreNotEqualDifferentNumbersTest() { var client = new NaturalPerson("Jan Kowalski", "11312737254"); var card = new ATMCard("1233567890", client, true, 1250.12m); var card2 = new ATMCard("1234567890", client, true, 1250.12m); Assert.AreNotEqual(card, card2); }
public void DebitCardsAreNotEqualDifferentOwnersTest() { var client = new NaturalPerson("Jan Kowalski", "11312737254"); var card = new DebitCard("1234567890", client, true, 1250.12m); var client2 = new NaturalPerson("Adam Nowak", "11397737254"); var card2 = new DebitCard("1234567890", client2, true, 1250.12m); Assert.AreNotEqual(card, card2); }
public void Add(SignUpViewModel model) { Customer exist = uow.RepostiryCustomer.Find(c => c.Email == model.Email && c.Status == false); if (!(exist is null)) { uow.RepostiryCustomer.Delete(exist); } Customer customer; if (model.CompanyName == null) { customer = new NaturalPerson() { Email = model.Email, Password = model.Password, FirstName = model.FirstName, LastName = model.LastName, PhoneNumber = model.PhoneNumber, Address = new Address() { PTT = model.Address.PTT, CityName = model.Address.CityName, StreetName = model.Address.StreetName, StreetNumber = model.Address.StreetNumber } }; } else { customer = new LegalEntity { Email = model.Email, Password = model.Password, CompanyName = model.CompanyName, TIN = model.TIN, PhoneNumber = model.PhoneNumber, Address = new Address() { PTT = model.Address.PTT, CityName = model.Address.CityName, StreetName = model.Address.StreetName, StreetNumber = model.Address.StreetNumber } }; } Random generateCode = new Random(); customer.VerificationCode = generateCode.Next(1000, 10000); SendEmail(customer.Email, "Activation code", $"Dear user, Your Activation Code is {customer.VerificationCode}"); uow.RepostiryCustomer.Add(customer); uow.Commit(); }
public static NaturalPersonDataContract GetNaturalPersonDC(this NaturalPerson naturalPerson) { return(new NaturalPersonDataContract() { FirstName = naturalPerson.FirstName, Id = naturalPerson.Id, LastName = naturalPerson.LastName, PrimaryEmail = naturalPerson.PrimaryEmail }); }
public void Add_Valid_Person_With_Address() { var person = new NaturalPerson( "Jorge Amado", "719.032.860-26", DateTime.Today, NaturalPerson.GenderType.Male, null); person.Address = new Address("Brazil", "Sao Paulo", "Sao Paulo", null, null, null); Assert.True(person.Address.Country == "Brazil"); Assert.True(person.Address.State == "Sao Paulo"); }
public async Task Delete(Guid id) { NaturalPerson person = await _naturalPersonRepository.GetById(id); _naturalPersonRepository.Delete(person); _addressRepository.Delete(person.Address); _documentRepository.Delete(person.Document); await _unitOfWork.Commit(); }
/// <summary> /// UPDATE PASS /// </summary> /// <param name="person"></param> /// <returns></returns> public static bool UpdatePass(NaturalPerson person) { string query = $"update u set u.ds_senha = '{person.Senha}' from tb_usuario as u inner join tb_pessoa_fisica " + $"on tb_pessoa_fisica.cd_usuario = u.cd_usuario where tb_pessoa_fisica.cd_cpf = '{person.CPF}';"; Commands bd = new Commands(); string selectProducts = query; return(bd.CommandExecute(selectProducts)); }
public void GetHashCodeTest() { var client = new NaturalPerson("Jan Kowalski", "11312737254"); var card1 = new ATMCard("1234567890", client, true, 1250.12m); var card2 = new CreditCard("1254367890", client, true, 1250.12m); var card3 = new DebitCard("1234587690", client, true, 1250.12m); Assert.AreEqual(1234567890, card1.GetHashCode()); Assert.AreEqual(1254367890, card2.GetHashCode()); Assert.AreEqual(1234587690, card3.GetHashCode()); }
public void BeCreatedAsNaturalPerson(string name, string countryId) { var naturalPerson = new NaturalPerson(); Assert.Equal(PersonType.NaturalPerson, naturalPerson.Type); naturalPerson.Name = name; naturalPerson.CountryId = countryId; Assert.Equal(name.ToUpperFirstLetterName(), naturalPerson.Name); Assert.Equal(countryId.NoSpecialChar(), naturalPerson.CountryId); }
public async Task <ActionResult <NaturalPerson> > Put(NaturalPerson person) { if (await _naturalPersonRepository.LoadEntityById(person.ID) != null) { return(Conflict("Already exists")); } await _unitOfWork.Save(person); var resourceUrl = $"{Request.Path.ToString()}/{Uri.EscapeUriString(person.ID.ToString())}"; return(Created(resourceUrl, person)); }
public async Task <IActionResult> AddHeater([Bind("NaturalPersonId,InstallerUserName,FullName,NationalCode,EmailAddress,PhoneNumber,MobileNumber,City,State,Address,PostalCode,InstallationLocation,GasometerType,GasometerNumber,PersonNumber,Attachment")] NaturalPerson naturalPerson) { if (ModelState.IsValid) { naturalPerson.NaturalPersonId = Guid.NewGuid(); naturalPerson.UserNaturalPerson = true; await UnitOfWork.NaturalPersonRepository.InsertAsync(naturalPerson); await UnitOfWork.SaveAsync(); } return(RedirectToAction("Create", "ReplacementHeater")); }
public IActionResult Post([FromBody] NaturalPerson item) { if (item == null) { return(BadRequest()); } item.Id = _context.NaturalPersons.Count() + 1; _context.NaturalPersons.Add(item); _context.SaveChanges(); return(CreatedAtRoute("GetNaturalPerson", new { id = item.Id }, item)); }
public static NaturalPersonDataContract ToNaturalPersonDataContract(this NaturalPerson naturalPerson) { return(new NaturalPersonDataContract() { Id = naturalPerson.Id, Age = naturalPerson.Age, FirstName = naturalPerson.FirstName, LastName = naturalPerson.LastName, NationalCode = naturalPerson.NationalCode, PrimaryEmail = naturalPerson.PrimaryEmail, Sexuality = naturalPerson.Sexuality }); }
public NaturalPersonModel(NaturalPerson naturalPerson) { Id = naturalPerson.Id; Name = naturalPerson.Name; CPF = naturalPerson.CPF; Birthday = naturalPerson.Birthday.ToString("yyyy-MM-dd"); Gender = naturalPerson.Gender; ZipCode = naturalPerson.Person?.ZipCode; Country = naturalPerson.Person?.Country; State = naturalPerson.Person?.State; City = naturalPerson.Person?.City; Address1 = naturalPerson.Person?.Address1; Address2 = naturalPerson.Person?.Address2; }
private bool checkIfPersonIsBusy(NaturalPerson person) { for (int i = 0; i < ((App)Application.Current).TaxesPayedByNatPersons.Count; i++) { var item = ((App)Application.Current).TaxesPayedByNatPersons[i]; if (item.PayerId == person.Id) { return(true); } } return(false); }
private void Check(NaturalPerson person, string areaCode, CalculatedFiscalCode expected) { var fiscalCode = provider.Calculate(person, new AreaCode(areaCode)); fiscalCode.LastName.Should().Be.EqualTo(expected.LastName); fiscalCode.FirstName.Should().Be.EqualTo(expected.FirstName); fiscalCode.Year.Should().Be.EqualTo(expected.Year); fiscalCode.Month.Should().Be.EqualTo(expected.Month); fiscalCode.Day.Should().Be.EqualTo(expected.Day); fiscalCode.Area.Should().Be.EqualTo(expected.Area); fiscalCode.Control.Should().Be.EqualTo(expected.Control); fiscalCode.Should().Be.EqualTo(expected); fiscalCode.IsValid.Should().Be.True(); }
public FiscalCode Calculate(NaturalPerson naturalPerson, AreaCode areaCode) { Enforce.Argument(() => areaCode); var lastName = new LastNameCode(naturalPerson.LastName.Replace(" ", null)); var firstName = new FirstNameCode(naturalPerson.FirstName.Replace(" ", null)); var year = new YearCode(naturalPerson.BirthDate); var month = new MonthCode(naturalPerson.BirthDate); var day = new DayCode(naturalPerson.BirthDate, naturalPerson.Sex); var control = new ControlCode(lastName, firstName, year, month, day, areaCode); var fiscalCode = new FiscalCode(lastName, firstName, year, month, day, areaCode, control); return fiscalCode; }
public ActionResult PostNaturalPerson(NaturalPerson person) { if (person != null) { Run("PersonController.Post(id)", () => { NaturalPerson.AddOrUpdate(i => i.Id, person); NotificationViewModel.AddToCookie("Processo finalizado com sucesso!", "Sucesso!", 10000, NotificationIconType.Success); }, person.Id); return RedirectToRoute("Person", new { id = person.Id }); } else { NotificationViewModel.AddToCookie("Ocorreu um problema ao salvar o registro!", iconType: NotificationIconType.Error); } return RedirectToRoute("Error", new { RedirectUrl = string.Format("~/cadastro/pessoa") }); }