Beispiel #1
0
        public async Task <ActionResult <int> > RegisterFirm(
            [FromBody] FirmAddressDto model)
        {
            var firmaddress = new FirmAddress
            {
                AptAddress    = (string)model.AptAddress,
                StreetAddress = (string)model.StreetAddress,
                City          = (string)model.City,
                State         = (string)model.State,
                ZipCode       = (string)model.Zip,
            };

            var addressId = await _dataAccess.CreateFirmAddressAsync(firmaddress);

            var firm = new Firm
            {
                Name      = (string)model.Name,
                Type      = (string)model.Type,
                AddressId = addressId
            };

            var firmId = await _dataAccess.CreateFirmAsync(firm);

            var user = await _dataAccess.GetUserByUserNameAsync(model.UserName);

            var firmUser = new FirmUser
            {
                FirmId = (int)firmId,
                UserId = (int)user.Id,
            };

            await _dataAccess.LinkFirmToUserAsync(firmUser);

            return(firmId);
        }
Beispiel #2
0
        private static IInfoRussiaDto ParseCard(XElement xml)
        {
            var firmAddressDto = new FirmAddressDto
            {
                Id     = (long)xml.Attribute("Code"),
                FirmId = (long)xml.Attribute("FirmCode"),
                ClosedForAscertainment = (bool?)xml.Attribute("IsHidden") ?? false,
                IsActive          = !((bool?)xml.Attribute("IsArchived") ?? false),
                IsDeleted         = (bool?)xml.Attribute("IsDeleted") ?? false,
                IsLocatedOnTheMap = (bool?)xml.Attribute("IsLocal") ?? true,
                Categories        = xml.Element("Rubrics")?.Elements("Rubric").Select(x => (int)x.Attribute("Code")) ?? Array.Empty <int>(),
            };

            var address = xml.Element("Address");

            if (address != null)
            {
                firmAddressDto.EntranceCode = (long?)address.Attribute("EntranceCode");
                firmAddressDto.BuildingId   = (long?)address.Attribute("BuildingCode");
            }

            return(firmAddressDto);
        }