Exemplo n.º 1
0
        public async Task <IActionResult> PutPhysicalPerson([FromRoute] Guid id, [FromBody] PhysicalPerson physicalPerson)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != physicalPerson.Id)
            {
                return(BadRequest());
            }

            _context.Entry(physicalPerson).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PhysicalPersonExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        // GET: Clients/Delete/5
        public async Task <IActionResult> Delete(int id)
        {
            var physicalClients = await PhysicalPerson.GetAll();

            var legalClients = await LegalRepository.GetAll();

            var client = await Repository.GetById(id : id);

            if (client == null)
            {
                return(NotFound());
            }

            var user = await _userManager.FindByNameAsync(client.Login);

            HttpContext.Session.Set <string>("IdIdentity", user.Id);

            if (client.PhysicalPerson != null)
            {
                return(View("DeletePhysicalPerson", new PhysicalPersonViewModel
                {
                    Client = client,
                    PhysicalPerson = client.PhysicalPerson
                }));
            }
            else
            {
                return(View("DeleteLegalPerson", new LegalPersonViewModel
                {
                    Client = client,
                    LegalPerson = client.LegalPerson
                }));
            }
        }
        public static PhysicalPersonViewModel ConvertToPhysicalPersonViewModelLite(this PhysicalPerson physicalPerson)
        {
            PhysicalPersonViewModel PhysicalPersonViewModel = new PhysicalPersonViewModel()
            {
                Id         = physicalPerson.Id,
                Identifier = physicalPerson.Identifier,

                Code = physicalPerson.Code,
                PhysicalPersonCode = physicalPerson.PhysicalPersonCode,
                Name    = physicalPerson.Name,
                SurName = physicalPerson.SurName,

                ConstructionSiteCode = physicalPerson.ConstructionSiteCode,
                ConstructionSiteName = physicalPerson.ConstructionSiteName,

                DateOfBirth = physicalPerson.DateOfBirth,

                Address  = physicalPerson.Address,
                Passport = physicalPerson.Passport,

                EmbassyDate    = physicalPerson.EmbassyDate,
                VisaFrom       = physicalPerson.VisaFrom,
                VisaTo         = physicalPerson.VisaTo,
                WorkPermitFrom = physicalPerson.WorkPermitFrom,
                WorkPermitTo   = physicalPerson.WorkPermitTo,

                IsActive = physicalPerson.Active,

                UpdatedAt = physicalPerson.UpdatedAt,
                CreatedAt = physicalPerson.CreatedAt
            };

            return(PhysicalPersonViewModel);
        }
        public async Task <IActionResult> Post([FromBody] CompanyProvidersCommands model)
        {
            var _companyProviders = await _companyProvidersRepository.GetByAsync(model);

            if (_companyProviders != null)
            {
                ModelState.AddModelError("cpF_CNPJ", "This cpf or cnpj already exists");
                return(BadRequest(ModelState));
            }

            if (model.Ativo == false)
            {
                var companyProviders = new CompanyProviders(model.Name, model.CPF_CNPJ, model.Ativo, model.CompanyId);
                return(Ok(await _companyProvidersRepository.CreateAsync(companyProviders)));
            }
            else
            {
                if ((model.Company.UF == UF.PR) && (model.Age < 18))
                {
                    ModelState.AddModelError("age", "Natural person of Parané must be of legal age");
                    return(BadRequest(ModelState));
                }

                var physicalPerson = new PhysicalPerson(model.Name, model.CPF_CNPJ, model.Ativo, model.CompanyId, model.DateBirth, model.RG, model.Age);
                return(Ok(await _companyProvidersRepository.CreateAsync(physicalPerson)));
            }

            throw new Exception("Exception while fetching all the Company Providers from the storage.");
        }
        public async Task <int> AddPhysicalPerson(PhysicalPerson physicalPerson)
        {
            var request = await _dbContext.PhysicalPerson.AddAsync(physicalPerson);

            await _dbContext.SaveChangesAsync();

            return(request.Entity.PersonId);
        }
        public static List <PhysicalPersonViewModel> ConvertToPhysicalPersonViewModelList(this IEnumerable <PhysicalPerson> PhysicalPersons)
        {
            List <PhysicalPersonViewModel> PhysicalPersonViewModels = new List <PhysicalPersonViewModel>();

            foreach (PhysicalPerson PhysicalPerson in PhysicalPersons)
            {
                PhysicalPersonViewModels.Add(PhysicalPerson.ConvertToPhysicalPersonViewModel());
            }
            return(PhysicalPersonViewModels);
        }
Exemplo n.º 7
0
        // GET: Clients
        public async Task <IActionResult> Index()
        {
            var clients = await Repository.GetAll();

            var physicalClients = await PhysicalPerson.GetAll();

            var legalClients = await LegalRepository.GetAll();

            return(View(model: clients));
        }
        public static PhysicalPersonViewModel ConvertToPhysicalPersonViewModel(this PhysicalPerson physicalPerson)
        {
            PhysicalPersonViewModel PhysicalPersonViewModel = new PhysicalPersonViewModel()
            {
                Id         = physicalPerson.Id,
                Identifier = physicalPerson.Identifier,

                Code = physicalPerson.Code,
                PhysicalPersonCode = physicalPerson.PhysicalPersonCode,
                Name    = physicalPerson.Name,
                SurName = physicalPerson.SurName,

                ConstructionSiteCode = physicalPerson.ConstructionSiteCode,
                ConstructionSiteName = physicalPerson.ConstructionSiteName,

                DateOfBirth = physicalPerson.DateOfBirth,
                Gender      = physicalPerson.Gender,

                Country      = physicalPerson.Country?.ConvertToCountryViewModelLite(),
                Region       = physicalPerson.Region?.ConvertToRegionViewModelLite(),
                Municipality = physicalPerson.Municipality?.ConvertToMunicipalityViewModelLite(),
                City         = physicalPerson.City?.ConvertToCityViewModelLite(),

                Address = physicalPerson.Address,

                PassportCountry = physicalPerson.PassportCountry?.ConvertToCountryViewModelLite(),
                PassportCity    = physicalPerson.PassportCity?.ConvertToCityViewModelLite(),
                Passport        = physicalPerson.Passport,
                VisaFrom        = physicalPerson.VisaFrom,
                VisaTo          = physicalPerson.VisaTo,

                ResidenceCountry = physicalPerson.ResidenceCountry?.ConvertToCountryViewModelLite(),
                ResidenceCity    = physicalPerson.ResidenceCity?.ConvertToCityViewModelLite(),
                ResidenceAddress = physicalPerson.ResidenceAddress,

                EmbassyDate    = physicalPerson.EmbassyDate,
                VisaDate       = physicalPerson.VisaDate,
                VisaValidFrom  = physicalPerson.VisaValidFrom,
                VisaValidTo    = physicalPerson.VisaValidTo,
                WorkPermitFrom = physicalPerson.WorkPermitFrom,
                WorkPermitTo   = physicalPerson.WorkPermitTo,

                IsActive = physicalPerson.Active,

                CreatedBy = physicalPerson.CreatedBy?.ConvertToUserViewModelLite(),
                Company   = physicalPerson.Company?.ConvertToCompanyViewModelLite(),

                UpdatedAt = physicalPerson.UpdatedAt,
                CreatedAt = physicalPerson.CreatedAt
            };

            return(PhysicalPersonViewModel);
        }
Exemplo n.º 9
0
        public async Task <IActionResult> PostPhysicalPerson([FromBody] PhysicalPerson physicalPerson)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.PhysicalPersons.Add(physicalPerson);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPhysicalPerson", new { id = physicalPerson.Id }, physicalPerson));
        }
Exemplo n.º 10
0
        public void Init()
        {
            var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson);
            var physicalLegalForm  = new LegalForm("ООО", EconomicAgentType.PhysicalPerson);

            juridicalPerson = new JuridicalPerson(juridicalLegalForm)
            {
                Id                 = 1,
                CashierName        = "Кассиров В.В.",
                DirectorName       = "Директоров В.В.",
                DirectorPost       = "Главный директор",
                INN                = "123456789",
                KPP                = "2020202020",
                MainBookkeeperName = "Главбухова А.А.",
                OGRN               = "12345",
                OKPO               = "5431"
            };

            physicalPerson = new PhysicalPerson(physicalLegalForm)
            {
                Id        = 2,
                INN       = "234567890",
                OGRNIP    = "23456",
                OwnerName = "Физиков Ф.Ф.",
                Passport  = new ValueObjects.PassportInfo
                {
                    Series         = "18 00",
                    Number         = "689689",
                    IssuedBy       = "Центральным РОВД г. Волгограда",
                    IssueDate      = DateTime.Parse("04.04.2001"),
                    DepartmentCode = "342-001"
                }
            };

            accountOrganization = new AccountOrganization("short_Name", "full_Name", juridicalPerson)
            {
                Id = 21
            };
            clientOrganization = new ClientOrganization("Короткое имя", "Длинное имя", physicalPerson)
            {
                Id = 22
            };
            providerOrganization = new ProviderOrganization("Краткое имя", "Полное имя", juridicalPerson)
            {
                Id = 23
            };

            provider = new Provider("Тестовый поставщик", new ProviderType("Тестовый тип поставщика"), ProviderReliability.Medium, 5);
            provider.AddContractorOrganization(providerOrganization);

            client = new Client("Тестовый клиент", new ClientType("Тестовый тип клиента"), ClientLoyalty.Follower,
                                new ClientServiceProgram("Программа"), new ClientRegion("Волгоград"), (byte)3);
        }
Exemplo n.º 11
0
        public FsspLibrary.Result[] Index(int code, string name, string lastname, string secondname)
        {
            var person = new PhysicalPerson()
            {
                Region     = code,
                Firsname   = name,
                Lastname   = lastname,
                Secondname = secondname
            };

            return(client.GetInfoPhysical(person));
        }
        public static PhysicalPerson ConvertToPhysicalPerson(this PhysicalPersonViewModel physicalPersonViewModel)
        {
            PhysicalPerson PhysicalPerson = new PhysicalPerson()
            {
                Id         = physicalPersonViewModel.Id,
                Identifier = physicalPersonViewModel.Identifier,

                Code = physicalPersonViewModel.Code,
                PhysicalPersonCode = physicalPersonViewModel.PhysicalPersonCode,
                Name    = physicalPersonViewModel.Name,
                SurName = physicalPersonViewModel.SurName,

                ConstructionSiteCode = physicalPersonViewModel.ConstructionSiteCode,
                ConstructionSiteName = physicalPersonViewModel.ConstructionSiteName,

                DateOfBirth    = (DateTime)physicalPersonViewModel.DateOfBirth,
                Gender         = physicalPersonViewModel.Gender,
                CountryId      = physicalPersonViewModel?.Country?.Id ?? null,
                RegionId       = physicalPersonViewModel?.Region?.Id ?? null,
                MunicipalityId = physicalPersonViewModel?.Municipality?.Id ?? null,
                CityId         = physicalPersonViewModel?.City?.Id ?? null,
                Address        = physicalPersonViewModel.Address,

                PassportCountryId = physicalPersonViewModel?.PassportCountry?.Id ?? null,
                PassportCityId    = physicalPersonViewModel?.PassportCity?.Id ?? null,

                Passport = physicalPersonViewModel.Passport,
                VisaFrom = physicalPersonViewModel.VisaFrom,
                VisaTo   = physicalPersonViewModel.VisaTo,

                ResidenceCountryId = physicalPersonViewModel?.ResidenceCountry?.Id ?? null,
                ResidenceCityId    = physicalPersonViewModel?.ResidenceCity?.Id ?? null,
                ResidenceAddress   = physicalPersonViewModel.ResidenceAddress,

                EmbassyDate    = physicalPersonViewModel.EmbassyDate,
                VisaDate       = physicalPersonViewModel.VisaDate,
                VisaValidFrom  = physicalPersonViewModel.VisaValidFrom,
                VisaValidTo    = physicalPersonViewModel.VisaValidTo,
                WorkPermitFrom = physicalPersonViewModel.WorkPermitFrom,
                WorkPermitTo   = physicalPersonViewModel.WorkPermitTo,

                CreatedById = physicalPersonViewModel.CreatedBy?.Id ?? null,
                CompanyId   = physicalPersonViewModel.Company?.Id ?? null,

                CreatedAt = physicalPersonViewModel.CreatedAt,
                UpdatedAt = physicalPersonViewModel.UpdatedAt
            };

            return(PhysicalPerson);
        }
Exemplo n.º 13
0
        static void Main1()
        {
            var _session = NHibernateHelper.OpenSession();
            var daoUser  = new UserDAO(_session);

            var user = new PhysicalPerson
            {
                Name = "Murilo"
            };

            daoUser.Add(user);

            _session.Close();

            Console.Read();
        }
Exemplo n.º 14
0
        public async Task <IActionResult> EditPhysicalPerson(PhysicalPersonViewModel physicalPersonViewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var client         = physicalPersonViewModel.Client;
                    var physicalPerson = new PhysicalPerson
                    {
                        IdPerson             = physicalPersonViewModel.Client.IdClient,
                        PassportSeries       = physicalPersonViewModel.PhysicalPerson.PassportSeries,
                        PassportNumber       = physicalPersonViewModel.PhysicalPerson.PassportNumber,
                        IdentificationNumber = physicalPersonViewModel.PhysicalPerson.IdentificationNumber,
                        Name       = physicalPersonViewModel.PhysicalPerson.Name,
                        Surname    = physicalPersonViewModel.PhysicalPerson.Surname,
                        Patronymic = physicalPersonViewModel.PhysicalPerson.Patronymic
                    };

                    await _clientRepository.UpdateAsync(entity : client);

                    await _physicalPersonRepository.UpdateAsync(physicalPerson);

                    var userId = HttpContext.Session.Get <string>(key: "IdIdentity");

                    var user = await _userManager.FindByIdAsync(userId : userId);

                    user.UserName    = physicalPersonViewModel.Client.Login;
                    user.Email       = physicalPersonViewModel.Client.Login;
                    user.PhoneNumber = physicalPersonViewModel.Client.TelNumber;

                    await _userManager.UpdateAsync(user : user);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientExists(id: physicalPersonViewModel.Client.IdClient))
                    {
                        return(NotFound());
                    }

                    throw;
                }

                return(RedirectToAction(actionName: nameof(Index)));
            }

            return(View(model: physicalPersonViewModel));
        }
Exemplo n.º 15
0
 public IActionResult Edit(long id, [Bind("Id,Name,LastName,GenderId,PersonalId,BirthDate,CityId,TelephoneTypeId,TelephoneNumber")] PhysicalPerson physicalPerson)
 {
     if (id != physicalPerson.Id)
     {
         return(NotFound());
     }
     try
     {
         _unitOfWork.PhysicalPersonRepository.Update(physicalPerson);
         _unitOfWork.Save();
     }
     catch (DbUpdateConcurrencyException)
     {
         throw;
     }
     return(RedirectToAction(nameof(Index)));
 }
Exemplo n.º 16
0
 private void AuthorizationPhysical_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         _physicalPerson = new PhysicalPerson(loginBox.Text, passwordBox.Password);
         if (_physicalPerson.Authorization())
         {
             _mainWindow = new MainWindow(_physicalPerson);
             _mainWindow.Show();
             Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
 }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            List <Person> list = new List <Person>();

            Console.Write("Enter the number of payers: ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                Console.WriteLine($"Tag player #{i} data:");
                Console.Write("Individual or company (i/c)? ");
                char word = char.Parse(Console.ReadLine());
                Console.Write("Name: ");
                string name = Console.ReadLine();
                Console.Write("Anual income: ");
                double anualIncome = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                if (word == 'i')
                {
                    Console.Write("Health expenditures: ");
                    double healthExpenditure = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                    Person physicalPerson    = new PhysicalPerson(name, anualIncome, healthExpenditure);
                    list.Add(physicalPerson);
                }
                else if (word == 'c')
                {
                    Console.Write("Number of employees: ");
                    int    numberOfEmployees = int.Parse(Console.ReadLine());
                    Person juridicPerson     = new JuridicPerson(name, anualIncome, numberOfEmployees);
                    list.Add(juridicPerson);
                }
            }

            Console.WriteLine();
            Console.WriteLine("TAXES PAID:");
            double sum = 0.0;

            foreach (Person obj in list)
            {
                Console.WriteLine(obj.ToString());
                sum += obj.TaxesPaid();
            }

            Console.WriteLine();
            Console.WriteLine("TOTAL TAXES: " + "$ " + sum.ToString("F2", CultureInfo.InvariantCulture));
        }
Exemplo n.º 18
0
        protected VipAttorneyRecognizedTrustScreenModel GetTrust(PhysicalPerson truster = null, Person attorney = null, VipAttorney trustBoxAttorney = null, TrustFinishDate trustFinishDate = null, TrustDate trustStartDate = null, CheckBoxDocField trusterSignature = null, CheckBoxDocField certifierSignature = null, CheckBoxDocField certifierStamp = null)
        {
            var doesntMatter = EditorMode.TrustsOperator;
            var startDate    = trustStartDate ?? DefaultDate();

            return(new VipAttorneyRecognizedTrustScreenModel(truster ?? DefaultPerson(),
                                                             attorney ?? DefaultPerson(),
                                                             trustBoxAttorney ?? GetDefaultVipAttorney(),
                                                             startDate,
                                                             trustFinishDate ?? (new TrustFinishDate(trustStartDate != null ? GetTrustDate(trustStartDate.Day.Value, trustStartDate.Month.Value, trustStartDate.Year.Value + 1) : DefaultDate(), startDate, DefaultNumberDocField(), TrustFinishDate.TrustFinishDateType.Custom)),

                                                             trusterSignature ?? DefaultCheckbox(),
                                                             certifierSignature ?? DefaultCheckbox(),
                                                             certifierStamp ?? DefaultCheckbox(),
                                                             doesntMatter,
                                                             new List <VipAttorney>(),
                                                             true));
        }
Exemplo n.º 19
0
 private void Reg_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (loginBox.Text == "Логин" && passwordBox.Password == "Password" && name.Text == "Имя" && surname.Text == "Фамилия")
         {
             throw new Exception("Измените начальные данные!");
         }
         _physicalPerson = new PhysicalPerson(loginBox.Text, passwordBox.Password, name.Text, surname.Text);
         if (_physicalPerson.Registration())
         {
             MessageBox.Show("Регистрация успешна!");
             _loginWindow = new LoginWindow();
             _loginWindow.Show();
             Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
 }
Exemplo n.º 20
0
        static void Main9()
        {
            var murilo = new PhysicalPerson
            {
                Name = "Murilo",
                CPF  = 11233433.ToString()
            };

            var caelum = new LegalPerson
            {
                Name = "Murilo",
                CNPJ = 11233433.ToString()
            };

            var _session = NHibernateHelper.OpenSession();
            var userDAO  = new UserDAO(_session);

            userDAO.Add(murilo);
            userDAO.Add(caelum);

            _session.Close();
            Console.Read();
        }
Exemplo n.º 21
0
        public async Task <TransportEntity> AddPhysicalPerson(AddPhysicalPersonCommand PhysicalPerson)
        {
            try
            {
                PhysicalPerson physicalPerson = new PhysicalPerson()
                {
                    Name              = PhysicalPerson.Name,
                    Birthdate         = PhysicalPerson.Birthday,
                    Documents         = PhysicalPerson.Documents.ToList(),
                    InternetAddresses = PhysicalPerson.InternetAddresses.ToList()
                };

                ObjReturn.Sucess = true;
                ObjReturn.Data   = await PhysicalPersonRepository.AddAsync(physicalPerson);

                return(ObjReturn);
            }
            catch (Exception ex)
            {
                ObjReturn.Sucess = false;
                ObjReturn.Messages.Add(ex.Message);
                return(ObjReturn);
            }
        }
Exemplo n.º 22
0
 public static PFisicaDTO MontarDTO(PhysicalPerson physical)
 => new PFisicaDTO(physical.Id, physical.Nome, physical.Cpf, physical.Rg, physical.DataNascimento, physical.Pessoa);
Exemplo n.º 23
0
        public PhysicalPersonResponse Create(PhysicalPersonViewModel physicalPerson)
        {
            PhysicalPersonResponse response = new PhysicalPersonResponse();

            try
            {
                //Backup items
                List <PhysicalPersonCardViewModel> physicalPersonCards = physicalPerson
                                                                         .PhysicalPersonCards?.ToList() ?? new List <PhysicalPersonCardViewModel>();
                physicalPerson.PhysicalPersonCards = null;

                List <PhysicalPersonDocumentViewModel> physicalPersonDocuments = physicalPerson
                                                                                 .PhysicalPersonDocuments?.ToList() ?? new List <PhysicalPersonDocumentViewModel>();
                physicalPerson.PhysicalPersonDocuments = null;

                List <PhysicalPersonItemViewModel> physicalPersonItems = physicalPerson
                                                                         .PhysicalPersonItems?.ToList() ?? new List <PhysicalPersonItemViewModel>();
                physicalPerson.PhysicalPersonItems = null;

                List <PhysicalPersonLicenceViewModel> physicalPersonLicences = physicalPerson
                                                                               .PhysicalPersonLicences?.ToList() ?? new List <PhysicalPersonLicenceViewModel>();
                physicalPerson.PhysicalPersonLicences = null;

                List <PhysicalPersonNoteViewModel> physicalPersonNotes = physicalPerson
                                                                         .PhysicalPersonNotes?.ToList() ?? new List <PhysicalPersonNoteViewModel>();
                physicalPerson.PhysicalPersonNotes = null;

                List <PhysicalPersonProfessionViewModel> physicalPersonProfessions = physicalPerson
                                                                                     .PhysicalPersonProfessions?.ToList() ?? new List <PhysicalPersonProfessionViewModel>();
                physicalPerson.PhysicalPersonProfessions = null;

                PhysicalPerson createdOutputInvoice = unitOfWork.GetPhysicalPersonRepository()
                                                      .Create(physicalPerson.ConvertToPhysicalPerson());

                // Update items
                if (physicalPersonCards != null && physicalPersonCards.Count > 0)
                {
                    foreach (PhysicalPersonCardViewModel item in physicalPersonCards
                             .Where(x => x.ItemStatus == ItemStatus.Added || x.ItemStatus == ItemStatus.Edited)?.ToList() ?? new List <PhysicalPersonCardViewModel>())
                    {
                        item.PhysicalPerson = new PhysicalPersonViewModel()
                        {
                            Id = createdOutputInvoice.Id
                        };
                        item.ItemStatus = ItemStatus.Submited;
                        var createdItem = unitOfWork.GetPhysicalPersonCardRepository().Create(item.ConvertToPhysicalPersonCard());
                    }

                    foreach (PhysicalPersonCardViewModel item in physicalPersonCards
                             .Where(x => x.ItemStatus == ItemStatus.Deleted)?.ToList() ?? new List <PhysicalPersonCardViewModel>())
                    {
                        item.PhysicalPerson = new PhysicalPersonViewModel()
                        {
                            Id = createdOutputInvoice.Id
                        };
                        unitOfWork.GetPhysicalPersonCardRepository().Create(item.ConvertToPhysicalPersonCard());

                        unitOfWork.GetPhysicalPersonCardRepository().Delete(item.Identifier);
                    }
                }

                // Update items
                if (physicalPersonDocuments != null && physicalPersonDocuments.Count > 0)
                {
                    foreach (PhysicalPersonDocumentViewModel item in physicalPersonDocuments
                             .Where(x => x.ItemStatus == ItemStatus.Added || x.ItemStatus == ItemStatus.Edited)?.ToList() ?? new List <PhysicalPersonDocumentViewModel>())
                    {
                        item.PhysicalPerson = new PhysicalPersonViewModel()
                        {
                            Id = createdOutputInvoice.Id
                        };
                        item.ItemStatus = ItemStatus.Submited;
                        var createdItem = unitOfWork.GetPhysicalPersonDocumentRepository().Create(item.ConvertToPhysicalPersonDocument());
                    }

                    foreach (PhysicalPersonDocumentViewModel item in physicalPersonDocuments
                             .Where(x => x.ItemStatus == ItemStatus.Deleted)?.ToList() ?? new List <PhysicalPersonDocumentViewModel>())
                    {
                        item.PhysicalPerson = new PhysicalPersonViewModel()
                        {
                            Id = createdOutputInvoice.Id
                        };
                        unitOfWork.GetPhysicalPersonDocumentRepository().Create(item.ConvertToPhysicalPersonDocument());

                        unitOfWork.GetPhysicalPersonDocumentRepository().Delete(item.Identifier);
                    }
                }

                // Update items
                if (physicalPersonItems != null && physicalPersonItems.Count > 0)
                {
                    foreach (PhysicalPersonItemViewModel item in physicalPersonItems
                             .Where(x => x.ItemStatus == ItemStatus.Added || x.ItemStatus == ItemStatus.Edited)?.ToList() ?? new List <PhysicalPersonItemViewModel>())
                    {
                        item.PhysicalPerson = new PhysicalPersonViewModel()
                        {
                            Id = createdOutputInvoice.Id
                        };
                        item.ItemStatus = ItemStatus.Submited;
                        var createdItem = unitOfWork.GetPhysicalPersonItemRepository().Create(item.ConvertToPhysicalPersonItem());
                    }

                    foreach (PhysicalPersonItemViewModel item in physicalPersonItems
                             .Where(x => x.ItemStatus == ItemStatus.Deleted)?.ToList() ?? new List <PhysicalPersonItemViewModel>())
                    {
                        item.PhysicalPerson = new PhysicalPersonViewModel()
                        {
                            Id = createdOutputInvoice.Id
                        };
                        unitOfWork.GetPhysicalPersonItemRepository().Create(item.ConvertToPhysicalPersonItem());

                        unitOfWork.GetPhysicalPersonItemRepository().Delete(item.Identifier);
                    }
                }

                // Update items
                if (physicalPersonLicences != null && physicalPersonLicences.Count > 0)
                {
                    foreach (PhysicalPersonLicenceViewModel item in physicalPersonLicences
                             .Where(x => x.ItemStatus == ItemStatus.Added || x.ItemStatus == ItemStatus.Edited)?.ToList() ?? new List <PhysicalPersonLicenceViewModel>())
                    {
                        item.PhysicalPerson = new PhysicalPersonViewModel()
                        {
                            Id = createdOutputInvoice.Id
                        };
                        item.ItemStatus = ItemStatus.Submited;
                        var createdItem = unitOfWork.GetPhysicalPersonLicenceRepository().Create(item.ConvertToPhysicalPersonLicence());
                    }

                    foreach (PhysicalPersonLicenceViewModel item in physicalPersonLicences
                             .Where(x => x.ItemStatus == ItemStatus.Deleted)?.ToList() ?? new List <PhysicalPersonLicenceViewModel>())
                    {
                        item.PhysicalPerson = new PhysicalPersonViewModel()
                        {
                            Id = createdOutputInvoice.Id
                        };
                        unitOfWork.GetPhysicalPersonLicenceRepository().Create(item.ConvertToPhysicalPersonLicence());

                        unitOfWork.GetPhysicalPersonLicenceRepository().Delete(item.Identifier);
                    }
                }

                // Update items
                if (physicalPersonNotes != null && physicalPersonNotes.Count > 0)
                {
                    foreach (PhysicalPersonNoteViewModel item in physicalPersonNotes
                             .Where(x => x.ItemStatus == ItemStatus.Added || x.ItemStatus == ItemStatus.Edited)?.ToList() ?? new List <PhysicalPersonNoteViewModel>())
                    {
                        item.PhysicalPerson = new PhysicalPersonViewModel()
                        {
                            Id = createdOutputInvoice.Id
                        };
                        item.ItemStatus = ItemStatus.Submited;
                        var createdItem = unitOfWork.GetPhysicalPersonNoteRepository().Create(item.ConvertToPhysicalPersonNote());
                    }

                    foreach (PhysicalPersonNoteViewModel item in physicalPersonNotes
                             .Where(x => x.ItemStatus == ItemStatus.Deleted)?.ToList() ?? new List <PhysicalPersonNoteViewModel>())
                    {
                        item.PhysicalPerson = new PhysicalPersonViewModel()
                        {
                            Id = createdOutputInvoice.Id
                        };
                        unitOfWork.GetPhysicalPersonNoteRepository().Create(item.ConvertToPhysicalPersonNote());

                        unitOfWork.GetPhysicalPersonNoteRepository().Delete(item.Identifier);
                    }
                }

                // Update items
                if (physicalPersonProfessions != null && physicalPersonProfessions.Count > 0)
                {
                    foreach (PhysicalPersonProfessionViewModel item in physicalPersonProfessions
                             .Where(x => x.ItemStatus == ItemStatus.Added || x.ItemStatus == ItemStatus.Edited)?.ToList() ?? new List <PhysicalPersonProfessionViewModel>())
                    {
                        item.PhysicalPerson = new PhysicalPersonViewModel()
                        {
                            Id = createdOutputInvoice.Id
                        };
                        item.ItemStatus = ItemStatus.Submited;
                        var createdItem = unitOfWork.GetPhysicalPersonProfessionRepository().Create(item.ConvertToPhysicalPersonProfession());
                    }

                    foreach (PhysicalPersonProfessionViewModel item in physicalPersonProfessions
                             .Where(x => x.ItemStatus == ItemStatus.Deleted)?.ToList() ?? new List <PhysicalPersonProfessionViewModel>())
                    {
                        item.PhysicalPerson = new PhysicalPersonViewModel()
                        {
                            Id = createdOutputInvoice.Id
                        };
                        unitOfWork.GetPhysicalPersonProfessionRepository().Create(item.ConvertToPhysicalPersonProfession());

                        unitOfWork.GetPhysicalPersonProfessionRepository().Delete(item.Identifier);
                    }
                }

                unitOfWork.Save();

                response.PhysicalPerson = createdOutputInvoice.ConvertToPhysicalPersonViewModel();
                response.Success        = true;
            }
            catch (Exception ex)
            {
                response.PhysicalPerson = new PhysicalPersonViewModel();
                response.Success        = false;
                response.Message        = ex.Message;
            }

            return(response);
        }
        public void Init()
        {
            // инициализация IoC
            IoCInitializer.Init();

            receiptWaybillRepository            = Mock.Get(IoCContainer.Resolve <IReceiptWaybillRepository>());
            articleRepository                   = Mock.Get(IoCContainer.Resolve <IArticleRepository>());
            storageRepository                   = Mock.Get(IoCContainer.Resolve <IStorageRepository>());
            movementWaybillRepository           = Mock.Get(IoCContainer.Resolve <IMovementWaybillRepository>());
            changeOwnerWaybillRepository        = Mock.Get(IoCContainer.Resolve <IChangeOwnerWaybillRepository>());
            writeoffWaybillRepository           = Mock.Get(IoCContainer.Resolve <IWriteoffWaybillRepository>());
            expenditureWaybillRepository        = Mock.Get(IoCContainer.Resolve <IExpenditureWaybillRepository>());
            returnFromClientWaybillRepository   = Mock.Get(IoCContainer.Resolve <IReturnFromClientWaybillRepository>());
            waybillRowArticleMovementRepository = Mock.Get(IoCContainer.Resolve <IWaybillRowArticleMovementRepository>());

            var incomingWaybillRowService = new IncomingWaybillRowService(receiptWaybillRepository.Object, movementWaybillRepository.Object,
                                                                          changeOwnerWaybillRepository.Object, returnFromClientWaybillRepository.Object);

            var outgoingWaybillRowService = new OutgoingWaybillRowService(movementWaybillRepository.Object, IoCContainer.Resolve <IWriteoffWaybillRepository>(),
                                                                          IoCContainer.Resolve <IExpenditureWaybillRepository>(), changeOwnerWaybillRepository.Object, waybillRowArticleMovementRepository.Object);

            var articleMovementService = new ArticleMovementService(waybillRowArticleMovementRepository.Object, receiptWaybillRepository.Object,
                                                                    movementWaybillRepository.Object, changeOwnerWaybillRepository.Object, returnFromClientWaybillRepository.Object,
                                                                    Mock.Get(IoCContainer.Resolve <IWriteoffWaybillRepository>()).Object, Mock.Get(IoCContainer.Resolve <IExpenditureWaybillRepository>()).Object,
                                                                    incomingWaybillRowService, outgoingWaybillRowService);

            articleAvailabilityService = new ArticleAvailabilityService(receiptWaybillRepository.Object,
                                                                        movementWaybillRepository.Object,
                                                                        changeOwnerWaybillRepository.Object,
                                                                        writeoffWaybillRepository.Object,
                                                                        expenditureWaybillRepository.Object,
                                                                        returnFromClientWaybillRepository.Object,
                                                                        articleRepository.Object,
                                                                        storageRepository.Object,
                                                                        IoCContainer.Resolve <IIncomingAcceptedArticleAvailabilityIndicatorService>(),
                                                                        IoCContainer.Resolve <IOutgoingAcceptedFromExactArticleAvailabilityIndicatorService>(),
                                                                        IoCContainer.Resolve <IOutgoingAcceptedFromIncomingAcceptedArticleAvailabilityIndicatorService>(),
                                                                        IoCContainer.Resolve <IExactArticleAvailabilityIndicatorService>(),
                                                                        incomingWaybillRowService);

            var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson);
            var physicalLegalForm  = new LegalForm("ИП", EconomicAgentType.PhysicalPerson);

            juridicalPerson = new JuridicalPerson(juridicalLegalForm)
            {
                Id = 1
            };
            physicalPerson = new PhysicalPerson(physicalLegalForm)
            {
                Id = 2
            };

            accountOrganization = new AccountOrganization("Тестовое юридическое лицо", "Тестовое юридическое лицо", juridicalPerson)
            {
                Id = 1
            };
            providerOrganization = new ProviderOrganization("Тестовое физическое лицо", "Тестовое физическое лицо", physicalPerson)
            {
                Id = 2
            };

            provider = new Provider("Тестовый поставщик", new ProviderType("Тестовый тип поставщика"), ProviderReliability.Medium, 5);
            provider.AddContractorOrganization(providerOrganization);

            providerContract = new ProviderContract(accountOrganization, providerOrganization, "ABC", "123", DateTime.Now, DateTime.Today);
            provider.AddProviderContract(providerContract);

            articleGroup = new ArticleGroup("Тестовая группа", "Тестовая группа");
            measureUnit  = new MeasureUnit("шт.", "Штука", "123", 0)
            {
                Id = 1
            };

            storageG = new Storage("G", StorageType.DistributionCenter)
            {
                Id = 1
            };
            storageM = new Storage("M", StorageType.DistributionCenter)
            {
                Id = 2
            };
            storageN = new Storage("N", StorageType.DistributionCenter)
            {
                Id = 3
            };

            articleA = new Article("A", articleGroup, measureUnit, false)
            {
                Id = 101
            };
            articleB = new Article("B", articleGroup, measureUnit, false)
            {
                Id = 102
            };
            articleC = new Article("C", articleGroup, measureUnit, false)
            {
                Id = 103
            };

            valueAddedTax = new ValueAddedTax("18%", 18);

            priceLists = new List <ArticleAccountingPrice>()
            {
                new ArticleAccountingPrice(articleA, 100), new ArticleAccountingPrice(articleB, 200),
                new ArticleAccountingPrice(articleC, 300)
            };
        }
Exemplo n.º 25
0
        public void Init()
        {
            articleGroup = new ArticleGroup("Бытовая техника", "Бытовая техника");
            articleGroup.SalaryPercent = 15;
            articleGroup.Id            = 8;

            measureUnit    = new MeasureUnit("шт.", "Штука", "123", 0);
            measureUnit.Id = 17;

            articleA = new Article("Пылесос", articleGroup, measureUnit, true)
            {
                Id = 29, Number = "ПЫЛ"
            };
            articleB = new Article("Холодильник", articleGroup, measureUnit, true)
            {
                Id = 38, Number = "ХО-1"
            };
            articleC = new Article("Плита газовая", articleGroup, measureUnit, true)
            {
                Id = 48, Number = "ПГ1"
            };

            articleAccountingPriceA1 = new ArticleAccountingPrice(articleA, 1M);
            articleAccountingPriceA2 = new ArticleAccountingPrice(articleA, 1001M);
            articleAccountingPriceA3 = new ArticleAccountingPrice(articleA, 1192.45M);
            articleAccountingPriceB  = new ArticleAccountingPrice(articleB, 150M);
            articleAccountingPriceC  = new ArticleAccountingPrice(articleC, 180M);

            articleAccountingPriceWrongListOnlyA = new List <ArticleAccountingPrice>();
            articleAccountingPriceWrongListOnlyA.Add(articleAccountingPriceA1);
            articleAccountingPriceWrongListOnlyA.Add(articleAccountingPriceA2);
            articleAccountingPriceWrongListOnlyA.Add(articleAccountingPriceA3);

            articleAccountingPriceCorrectList1 = new List <ArticleAccountingPrice>();
            articleAccountingPriceCorrectList1.Add(articleAccountingPriceA2);
            articleAccountingPriceCorrectList1.Add(articleAccountingPriceB);
            articleAccountingPriceCorrectList1.Add(articleAccountingPriceC);

            storage1 = new Storage("Торговая точка номер 1", StorageType.TradePoint);
            storage2 = new Storage("Доп. склад северный", StorageType.ExtraStorage);
            storage3 = new Storage("Торговая точка номер 2", StorageType.TradePoint);

            storageList1 = new List <Storage>();
            storageList1.Add(storage1);
            storageList1.Add(storage2);
            storageList1.Add(storage3);

            var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson);
            var physicalLegalForm  = new LegalForm("ИП", EconomicAgentType.PhysicalPerson);

            juridicalPerson = new JuridicalPerson(juridicalLegalForm)
            {
                Id = 1
            };
            physicalPerson = new PhysicalPerson(physicalLegalForm)
            {
                Id = 2
            };

            accountOrganization = new AccountOrganization("Тестовое юридическое лицо", "Тестовое юридическое лицо", juridicalPerson)
            {
                Id = 1
            };
            providerOrganization = new ProviderOrganization("Тестовое физическое лицо", "Тестовое физическое лицо", physicalPerson)
            {
                Id = 2
            };

            provider = new Provider("Тестовый поставщик", new ProviderType("Тестовый тип поставщика"), ProviderReliability.Medium, 5);
            provider.AddContractorOrganization(providerOrganization);

            providerContract = new ProviderContract(accountOrganization, providerOrganization, "ABC", "123", DateTime.Now, DateTime.Today);
            provider.AddProviderContract(providerContract);

            user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null);
            var customDeclarationNumber = new String('0', 25);

            receiptWaybill = new ReceiptWaybill("123АБВ", DateTime.Today, storage1, accountOrganization, provider, 100.05M, 0M, new ValueAddedTax("18%", 18), providerContract, customDeclarationNumber, user, user, DateTime.Now);

            priceRule = new AccountingPriceCalcRule(
                new AccountingPriceCalcByPurchaseCost(PurchaseCostDeterminationRuleType.ByMinimalPurchaseCost, new MarkupPercentDeterminationRule(10)));
            digitRule = new LastDigitCalcRule(LastDigitCalcRuleType.SetCustom);

            user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null);
        }
Exemplo n.º 26
0
 public bool Save(PhysicalPerson PhysicalPerson)
 {
     _PhysicalPersonApp.InsertOrUpdate(PhysicalPerson);
     return(_connection.Save());
 }
Exemplo n.º 27
0
 public async Task <IActionResult> AddPhysicalPerson(PhysicalPerson command)
 {
     return(Ok(await mediator.Send(command.CreateCommand())));
 }
Exemplo n.º 28
0
 public bool InsertOrUpdate(PhysicalPerson PhysicalPerson)
 {
     return(_epr.InsertOrUpdate(PhysicalPerson));
 }
Exemplo n.º 29
0
 public IActionResult Create([Bind("Id,Name,LastName,GenderId,PersonalId,BirthDate,CityId,TelephoneTypeId,TelephoneNumber")] PhysicalPerson physicalPerson)
 {
     _unitOfWork.PhysicalPersonRepository.Insert(physicalPerson);
     _unitOfWork.Save();
     return(RedirectToAction(nameof(Index)));
 }
Exemplo n.º 30
0
        public ActionResult RegisterPhysicalPerson(PhysicalPersonRegistrationViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var firstError = ModelState.Values.Where(x => x.Errors.Any()).FirstOrDefault();

                    ValidationUtils.IsNull(firstError, firstError.Errors.FirstOrDefault().ErrorMessage);
                }

                var currentDateTime = DateTimeUtils.GetCurrentDateTime();

                var registrationAddressCityId = ValidationUtils.TryGetShort(model.RegistrationAddressCityId, "Неверное значение входного параметра.");
                var postalAddressCityId       = ValidationUtils.TryGetShort(model.PostalAddressCityId, "Неверное значение входного параметра.");
                var rateId = ValidationUtils.TryGetShort(model.RateId, "Неверное значение входного параметра.");

                var extraUserCount                = ValidationUtils.TryGetShort(model.ExtraUserCount);
                var extraTeamCount                = ValidationUtils.TryGetShort(model.ExtraTeamCount);
                var extraStorageCount             = ValidationUtils.TryGetShort(model.ExtraStorageCount);
                var extraAccountOrganizationCount = ValidationUtils.TryGetShort(model.ExtraAccountOrganizationCount);
                var extraGigabyteCount            = ValidationUtils.TryGetShort(model.ExtraGigabyteCount);

                using (IUnitOfWork uow = unitOfWorkFactory.Create(IsolationLevel.Serializable))
                {
                    var registrationAddressCity = cityRepository.GetById(registrationAddressCityId);
                    ValidationUtils.NotNull(registrationAddressCity, "Город не найден.");

                    var registrationAddress = new Address(registrationAddressCity, model.RegistrationAddressPostalIndex, model.RegistrationAddressLocalAddress);

                    var rate = rateRepository.GetById(rateId);
                    ValidationUtils.NotNull(rate, "Тариф не найден.");

                    Address postalAddress = null;

                    if (model.PostalAddressEqualsRegistration)
                    {
                        postalAddress = new Address(registrationAddress.City, registrationAddress.PostalIndex, registrationAddress.LocalAddress);
                    }
                    else
                    {
                        var postalAddressCity = cityRepository.GetById(postalAddressCityId);
                        ValidationUtils.NotNull(postalAddressCityId, "Город не найден.");

                        postalAddress = new Address(postalAddressCity, model.PostalAddressPostalIndex, model.PostalAddressLocalAddress);
                    }

                    var client = new PhysicalPerson(model.LastName, model.FirstName, model.Patronymic, model.INNIP, registrationAddress, postalAddress, currentDateTime);

                    client.AdminEmail   = model.AdminEmail;
                    client.DBServerName = AppSettings.ClientDBServerName;
                    client.OGRNIP       = model.OGRNIP;
                    client.Phone        = model.Phone;
                    client.PromoCode    = model.PromoCode;

                    clientRepository.Save(client);

                    client.DBName = "bizpulse_" + client.Number.ToString();

                    var admin = new ClientUser(model.AdminLastName, model.AdminFirstName, model.AdminLogin, CryptographyUtils.ComputeHash(model.AdminPassword),
                                               true, currentDateTime);
                    admin.Patronymic = model.AdminPatronymic;

                    client.AddUser(admin);

                    // добавление первого набора услуг и первой услуги в набор
                    client.CreateInitialServiceSet(client, rate, extraUserCount, extraTeamCount, extraStorageCount,
                                                   extraAccountOrganizationCount, extraGigabyteCount, currentDateTime);

                    uow.Commit();

                    // создание БД клиента
                    CreateClientDatabase(client, currentDateTime);

                    // отправка письма о регистрации
                    SendRegistrationLetter(client, admin, model.AdminPassword);

                    return(Content(client.Id.ToString()));
                }
            }
            catch (Exception ex)
            {
                return(Content(ProcessException(ex)));
            }
        }