public string UpdatePerson(PersonDto personDto)
 {
     try
     {
         Guid id = personDto.Id;
         PersonRepository repository = new PersonRepository();
         Person person = repository.ActiveContext.Persons.Where(p => p.Id == id).FirstOrDefault();
         if (person == null) return ("person is not found and will not be updated ");
         person.InjectFrom<UnflatLoopValueInjection>(personDto);
         person.ContactInfo.InjectFrom<UnflatLoopValueInjection>(personDto);
         repository.Update(person);
         return ("updated successfully");
     }
     catch (Exception exception)
     {
         return exception.Message;
     }
 }
 /// <summary>
 /// person region
 /// </summary>
 /// <param name="personDto"></param>
 public string AddPerson(PersonDto personDto)
 {
     try
     {
         string nationalIdentity = personDto.NationalIdentity;
         PersonRepository repository = new PersonRepository();
         if (repository.ActiveContext.Persons.Where(p => p.NationalIdentity == nationalIdentity).Count() != 0) return "person with this natinal identity is there ";
         personDto.CustomerId =
             repository.ActiveContext.Persons.Select(o => o.CustomerId).DefaultIfEmpty(0).Max() + 1;
         personDto.Id = Guid.NewGuid();
         Person person = new Person();
         person.InjectFrom<UnflatLoopValueInjection>(personDto);
         person.ContactInfo.InjectFrom<UnflatLoopValueInjection>(personDto);
         repository.Add(person);
         return "person is added successfully by customerId :" + personDto.CustomerId.ToString();
     }
     catch (Exception exception)
     {
         return exception.Message;
     }
 }
Exemple #3
0
 public void AddPersonTest1(Guid id)
 {
     PersonDto personDto = new PersonDto();
       personDto.HeadNationalIdentity = "1245";
       personDto.Id = id;
       personDto.CustomerId = 10;
       personDto.Firstname = "ali";
       personDto.FatherName = "ahmad";
       personDto.Lastname = "rezai";
       personDto.ShobehCode = 1;
       personDto.HomeAddress = "babol";
       personDto.HomeTelno = "145789+";
       personDto.NationalIdentity = "198598";
       PersonAccountService pa = new PersonAccountService();
       string str = pa.AddPerson(personDto);
 }
Exemple #4
0
 public int AddPersonTest2()
 {
     PersonAccountService pa = new PersonAccountService();
     PersonDto personDto = new PersonDto
         {
             BirthDate = 13910102,
             CretyId = "1",
             CretySerial = "2",
             FatherName = "ahmad",
             Firstname = "ali",
             HomeAddress = "babol",
             NationalIdentity = "1",
             HomeTelno = "1245",
             HeadNationalIdentity = "2"
         };
     pa.AddPerson(personDto);
     return 100;
 }
Exemple #5
0
 public void AddPersonTest()
 {
     PersonDto personDto = new PersonDto();
     personDto.HeadNationalIdentity = "12451";
     //personDto.Id = Guid.NewGuid();
        // personDto.CustomerId = 10;
     personDto.Firstname = "ali1";
     personDto.FatherName = "ahmad1";
     personDto.Lastname = "rezai1";
     personDto.ShobehCode = 11;
     personDto.HomeAddress = "babol1";
     personDto.HomeTelno = "145789+";
     personDto.NationalIdentity = "56457611";
     PersonAccountService pa = new PersonAccountService();
     string str = pa.AddPerson(personDto);
 }