public void ManageManyToManyRelation()
        {
            var firstAddress = new AddressEntity("1st address");
            var secondAddress = new AddressEntity("2nd address");

            var firstPerson = new PersonEntity("1st person");
            var secondPerson = new PersonEntity("2nd person");

            firstAddress.AddPerson(firstPerson);
            this.AssertBound(firstPerson, firstAddress);
            this.AssertUnbound(firstPerson, secondAddress);
            this.AssertUnbound(secondPerson, firstAddress);

            secondPerson.AddAddress(secondAddress);
            this.AssertBound(secondPerson, secondAddress);
            this.AssertUnbound(secondPerson, firstAddress);
            this.AssertUnbound(firstPerson, secondAddress);

            firstAddress.AddPerson(secondPerson);
            this.AssertBound(firstPerson, firstAddress);
            this.AssertUnbound(firstPerson, secondAddress);
            this.AssertBound(secondPerson, firstAddress);

            secondPerson.AddAddress(firstAddress);
            this.AssertBound(firstPerson, firstAddress);
            this.AssertUnbound(firstPerson, secondAddress);
            this.AssertBound(secondPerson, firstAddress);
            this.AssertBound(secondPerson, secondAddress);

            secondAddress.AddPerson(firstPerson);
            this.AssertBound(firstPerson, firstAddress);
            this.AssertBound(firstPerson, secondAddress);
            this.AssertBound(secondPerson, firstAddress);
            this.AssertBound(secondPerson, secondAddress);

            firstAddress.RemovePerson(firstPerson);
            this.AssertUnbound(firstPerson, firstAddress);
            this.AssertBound(firstPerson, secondAddress);
            this.AssertBound(secondPerson, firstAddress);
            this.AssertBound(secondPerson, secondAddress);

            secondPerson.RemoveAddress(firstAddress);
            this.AssertUnbound(firstPerson, firstAddress);
            this.AssertBound(firstPerson, secondAddress);
            this.AssertUnbound(secondPerson, firstAddress);
            this.AssertBound(secondPerson, secondAddress);

            firstPerson.RemoveAddress(secondAddress);
            this.AssertUnbound(firstPerson, firstAddress);
            this.AssertUnbound(firstPerson, secondAddress);
            this.AssertUnbound(secondPerson, firstAddress);
            this.AssertBound(secondPerson, secondAddress);

            secondAddress.RemovePerson(secondPerson);
            this.AssertUnbound(firstPerson, firstAddress);
            this.AssertUnbound(firstPerson, secondAddress);
            this.AssertUnbound(secondPerson, firstAddress);
            this.AssertUnbound(secondPerson, secondAddress);
        }
Example #2
0
 public static List <AddressEntity> Mapper(List <AddressModel> addressModel)
 {
     if (addressModel != null)
     {
         List <AddressEntity> addressesEntity = new List <AddressEntity>();
         foreach (var item in addressModel)
         {
             AddressEntity addressEntity = new AddressEntity
             {
                 Id           = item.Id,
                 CEP          = item.CEP,
                 City         = item.City,
                 Neighborhood = item.Neighborhood,
                 Country      = item.Country,
                 Number       = item.Number,
                 State        = item.State,
                 Street       = item.Street
             };
             addressesEntity.Add(addressEntity);
         }
         return(addressesEntity);
     }
     return(null);
 }
        public bool NoChanges(AddressEntity address, AddressModel addressModel)
        {
            if (!string.Equals(address.AddressStreet, addressModel.Street))
            {
                return(false);
            }

            if (!string.Equals(address.AddressStreetNo, addressModel.StreetNo))
            {
                return(false);
            }

            if (!string.Equals(address.AddressCity, addressModel.City))
            {
                return(false);
            }

            if (!string.Equals(address.AddressCountry, addressModel.Country))
            {
                return(false);
            }

            return(true);
        }
Example #4
0
        /// <summary>
        /// 编辑地址
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Edit(AddressEntity model)
        {
            string sql = @"Update AddressInfo Set ProvinceId=@ProvinceId,CityId=@CityId,AreaId=@AreaId,PostCode=@PostCode,Address=@Address,Receiver=@Receiver,Phone=@Phone,
                           PapersType=@PapersType,PapersCode=@PapersCode,UpdateTime=@UpdateTime,UpdateBy=@UpdateBy
                           Where Id=@Id And UserId=@UserId;";

            var parameters = DbSFO2ORead.CreateParameterCollection();

            parameters.Append("@ProvinceId", model.ProvinceId);
            parameters.Append("@CityId", model.CityId);
            parameters.Append("@AreaId", model.AreaId);
            parameters.Append("@PostCode", model.PostCode);
            parameters.Append("@Address", model.Address);
            parameters.Append("@Receiver", model.Receiver);
            parameters.Append("@Phone", model.Phone);
            parameters.Append("@PapersType", model.PapersType);
            parameters.Append("@PapersCode", model.PapersCode);
            parameters.Append("@UpdateTime", model.UpdateTime);
            parameters.Append("@UpdateBy", model.UpdateBy);
            parameters.Append("@Id", model.Id);
            parameters.Append("@UserId", model.UserId);

            return(DbSFO2OMain.ExecuteNonQuery(CommandType.Text, sql, parameters) > 0);
        }
Example #5
0
        public bool EditAddre(AddressEntity address)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update  tbAddress set");
            strSql.Append("address_name=@AddressName,vip_id@VipID");
            strSql.Append("where id=@AddressID");
            SqlParameter[] paras =
            {
                new SqlParameter("@AddressName", address.AddressName),
                new SqlParameter("@VipID",       address.VipID),
                new SqlParameter("@AddressID",   address.AddressID)
            };
            object obj = SqlHelper.ExecuteNonQuery(SqlHelper.connStr, CommandType.Text, strSql.ToString(), paras);

            if (Convert.ToInt32(obj) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public async Task <IActionResult> LoginShoppingUser([FromBody] LoginUser user, CancellationToken ct)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(new { error = "Model state is not valid" });
            //}

            //var result = await _baseSignInManager.PasswordSignInAsync(user.Email, user.Password, false, false);

            //if (!result.Succeeded)
            //{
            //    return BadRequest(new { error = $"Unable to sign in user {user.Email}" });
            //}

            var shoppingUserEntity = await _baseUserManager.FindByEmailAsync(user.Email) as ShoppingUserEntity;

            //// Get Home Store Information
            StoreEntity storeEntity = await _storeRepository.GetEntityAsync(shoppingUserEntity.HomeStoreId, ct);

            AddressEntity addressEntity = await _addressRepository.GetEntityAsync(storeEntity.AddressId, ct);

            Store   mappedStore = Mapper.Map <Store>(storeEntity);
            Address address     = Mapper.Map <Address>(addressEntity);

            mappedStore.Address = address;

            var shoppingUser = new ShoppingUser
            {
                Token     = CreateToken(shoppingUserEntity),
                FullName  = $"{shoppingUserEntity.FirstName}, {shoppingUserEntity.LastName}",
                Email     = shoppingUserEntity.Email,
                HomeStore = mappedStore
            };

            return(Ok(shoppingUser));
        }
Example #7
0
        public AddressEntity UpdateCompanyAddress(int companyId, AddressEntity address)
        {
            this.CheckCompanyAddressForUpdate(companyId, address.Id);

            return(_addressService.UpdateCompanyAddress(address));
        }
 public void AddAddress(AddressEntity addressEntity)
 {
     this.m_personAddressesAssociation.Add(addressEntity);
 }
 /// <summary>
 /// Converts to order address.
 /// </summary>
 /// <param name="address">The address.</param>
 /// <returns></returns>
 private static OrderAddress ConvertToOrderAddress(AddressEntity address)
 {
     return new OrderAddress(address);
 }
Example #10
0
        /// <summary>
        /// 设置用户收货地址信息
        /// </summary>
        /// <param name="sid"></param>
        /// <param name="token"></param>
        /// <param name="userId"></param>
        /// <param name="uid"></param>
        /// <param name="address"></param>
        /// <returns></returns>
        public static MResult <int> SetAddress(string sid, string token, int userId, string uid, AddressEntity address)
        {
            var result = new MResult <int>();

            try
            {
                if (address != null && userId > 0)
                {
                    var member = DALFactory.Member();

                    #region 地址实体类转换
                    var userAddress = new User_Consignee_Address
                    {
                        intAddressID     = address.id,
                        intUserID        = userId,
                        vchConsignee     = address.contact_name,
                        vchCAName        = address.name,
                        vchPhone         = address.phone,
                        vchMobile        = address.mobile,
                        intAddrType      = address.type,
                        intStateID       = address.province_id,
                        vchStateName     = address.province,
                        intCityID        = address.city_id,
                        vchCityName      = address.city,
                        intCountyID      = address.county_id,
                        vchCountyName    = address.county,
                        vchDetailAddr    = address.addr,
                        vchPostCode      = address.zip,
                        intIsDefaultAddr = (byte)(address.get_def ? 1 : 0),
                        dtLastModTime    = address.modify_date,
                        intDeliverID     = address.deliver_id,
                        intPayID         = address.pay_id,
                    };
                    #endregion

                    //查询用户地址库数量
                    var addressCount = member.GetMemberAddressCount(userId);

                    #region 如果用户第一次添加地址,则设为默认地址
                    if (addressCount == 0)
                    {
                        userAddress.intIsDefaultAddr = 1;
                    }
                    #endregion

                    #region 如果设置了 默认收货地址,则需要清空之前所有地址的默认状态
                    if (userAddress.intIsDefaultAddr == 1)
                    {
                        member.ReSetAddressDefaultStatus(userId);
                    }
                    #endregion

                    #region 如果 地址id > 0 则需要更新
                    if (address.id > 0)
                    {
                        userAddress.dtLastModTime = DateTime.Now;
                        if (member.UpdateMemberAddress(address.id, userAddress))
                        {
                            result.status = MResultStatus.Success;
                        }
                        else
                        {
                            result.status = MResultStatus.ExecutionError;
                            result.msg    = "更新收货地址失败!";
                        }
                    }
                    #endregion

                    #region 否则 添加操作
                    else
                    {
                        #region 判断用户地址是否已存在
                        var addresExists = member.CheckAddresExists(userAddress);
                        if (addresExists)
                        {
                            result.status = MResultStatus.ExecutionError;
                            result.msg    = "该收货地址已存在!";
                            return(result);
                        }
                        #endregion

                        #region 判断用户地址数量
                        if (addressCount >= 10)
                        {
                            result.status = MResultStatus.ExecutionError;
                            result.msg    = "您最多只能保存10个收货地址!";
                            return(result);
                        }
                        #endregion

                        userAddress.dtAddTime     = DateTime.Now;
                        userAddress.dtLastModTime = DateTime.Now;
                        result.info = member.AddMemberAddress(userAddress);
                        if (result.info > 0)
                        {
                            result.status = MResultStatus.Success;
                        }
                        else
                        {
                            result.status = MResultStatus.ExecutionError;
                            result.msg    = "添加收货地址失败!";
                        }
                    }
                    #endregion
                }
                else
                {
                    result.status = MResultStatus.ParamsError;
                    result.msg    = "参数错误!";
                }
            }
            catch (Exception)
            {
                result.status = MResultStatus.ExceptionError;
                result.msg    = "设置用户收货地址信息 异常!";
            }
            return(result);
        }
 public AddressEntity UpdateCompanyAddress(AddressEntity address)
 {
     return(_repository.UpdateCompanyAddress(address));
 }
 private void AssertUnbound(PersonEntity person, AddressEntity address)
 {
     Assert.False(person.Addresses.Contains(address));
     Assert.False(address.People.Contains(person));
 }
 public Delivery(DeliveryType deliveryType = DeliveryType.Address)
 {
     DeliveryType    = deliveryType;
     DeliveryAddress = new AddressEntity(AddressType.DeliveryAddress);
 }
        public async Task <IActionResult> ChangeHomeStore(int id, CancellationToken ct)
        {
            var currentUser  = HttpContext.User;
            var userclaim    = currentUser.Claims.First();
            var userId       = Guid.Parse(userclaim.Value);
            var shoppingUser = await _shoppingUserRepository.GetEntityAsync(userId, ct);

            if (shoppingUser == null)
            {
                return(BadRequest("You are not a shopping user"));
            }

            var store = await _storeRepository.GetEntityAsync(id, ct);

            shoppingUser.HomeStoreId = store.Id;

            var updatedUser = await _shoppingUserRepository.UpdateEntity(shoppingUser, ct);

            if (updatedUser.HomeStoreId != store.Id)
            {
                return(BadRequest("Error updating users store"));
            }

            AddressEntity addressEntity = await _addressRepository.GetEntityAsync(store.AddressId, ct);

            Store   mappedStore = Mapper.Map <Store>(store);
            Address address     = Mapper.Map <Address>(addressEntity);

            mappedStore.Address = address;

            StoreMapEntity map = await _storeMapRepository.GetEntityAsync(store.StoreMapId, ct);

            StoreMap newMap = Mapper.Map <StoreMap>(map);

            mappedStore.StoreMap = newMap;

            var lists = await _shoppingListRepository.GetAllShoppingListsForUserForACertainStore(shoppingUser.Id, mappedStore.Id, ct);

            List <ShoppingList> newlist = new List <ShoppingList>();

            //sle = ShoppingListEntity
            foreach (var sle in lists)
            {
                ShoppingList sl = new ShoppingList
                {
                    Name = sle.Name,
                    //Store = mappedStore,
                    TimeOfCreation = sle.TimeOfCreation,
                    Id             = sle.Id
                };

                var itemListLinkEntities = await _itemListLinkRepository.GetAllByShoppingListId(sle.Id, ct);

                foreach (var itemlistlink in itemListLinkEntities)
                {
                    ShoppingListItem item = await GetFullItemInfo(itemlistlink, sle.StoreId, ct);

                    sl.Items.Add(item);
                }

                sl.TotalCost  = sl.Items.Select(i => i.Price * i.ItemQuantity).ToList().Sum();
                sl.TotalItems = sl.Items.Select(i => i.ItemQuantity).ToList().Sum();

                newlist.Add(sl);
            }

            var updatedUserApp = new ShoppingUser
            {
                FullName      = $"{shoppingUser.FirstName} {shoppingUser.LastName}",
                Email         = shoppingUser.Email,
                HomeStore     = mappedStore,
                ShoppingLists = newlist,
                Role          = "Shopping"
            };

            return(Ok(updatedUserApp));
        }
Example #15
0
 public void Save(AddressEntity alunoEntity)
 {
     AddressRepository.Save(alunoEntity);
 }
        public async Task <IActionResult> LoginUser([FromBody] LoginUser user, CancellationToken ct)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new { error = "Model state is not valid" }));
            }

            var result = await _baseSignInManager.PasswordSignInAsync(user.Email, user.Password, false, false);

            if (!result.Succeeded)
            {
                return(BadRequest(new { error = $"Unable to sign in user {user.Email}" }));
            }

            var userEntity = await _baseUserManager.FindByEmailAsync(user.Email);

            var rolenames = await _baseUserManager.GetRolesAsync(userEntity) as List <string>;

            if (rolenames[0] == "Shopping")
            {
                try
                {
                    var         shoppingUserEntity = userEntity as ShoppingUserEntity;
                    StoreEntity storeEntity        = await _storeRepository.GetEntityAsync(shoppingUserEntity.HomeStoreId, ct);

                    AddressEntity addressEntity = await _addressRepository.GetEntityAsync(storeEntity.AddressId, ct);

                    Store   mappedStore = Mapper.Map <Store>(storeEntity);
                    Address address     = Mapper.Map <Address>(addressEntity);
                    mappedStore.Address = address;

                    StoreMapEntity map = await _storeMapRepository.GetEntityAsync(storeEntity.StoreMapId, ct);


                    StoreMap newMap = Mapper.Map <StoreMap>(map);

                    mappedStore.StoreMap = newMap;

                    var lists = await _shoppingListRepository.GetAllShoppingListsForUserForACertainStore(shoppingUserEntity.Id, mappedStore.Id, ct);

                    List <ShoppingList> newlist = new List <ShoppingList>();

                    //sle = ShoppingListEntity
                    foreach (var sle in lists)
                    {
                        ShoppingList sl = new ShoppingList
                        {
                            Name = sle.Name,
                            //Store = mappedStore,
                            TimeOfCreation = sle.TimeOfCreation,
                            Id             = sle.Id
                        };

                        var itemListLinkEntities = await _itemListLinkRepository.GetAllByShoppingListId(sle.Id, ct);

                        foreach (var itemlistlink in itemListLinkEntities)
                        {
                            ShoppingListItem item = await GetFullItemInfo(itemlistlink, sle.StoreId, ct);

                            sl.Items.Add(item);
                        }

                        sl.TotalCost  = sl.Items.Select(i => i.Price * i.ItemQuantity).ToList().Sum();
                        sl.TotalItems = sl.Items.Select(i => i.ItemQuantity).ToList().Sum();

                        newlist.Add(sl);
                    }

                    var shoppingUser = new ShoppingUser
                    {
                        Token         = CreateToken(shoppingUserEntity),
                        FullName      = $"{shoppingUserEntity.FirstName} {shoppingUserEntity.LastName}",
                        Email         = shoppingUserEntity.Email,
                        HomeStore     = mappedStore,
                        ShoppingLists = newlist,
                        Role          = "Shopping"
                    };

                    var response = new ObjectResult(shoppingUser)
                    {
                        StatusCode = (int)HttpStatusCode.OK
                    };

                    Request.HttpContext.Response.Headers.Add("authorization", shoppingUser.Token);


                    return(response);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
            else if (rolenames[0] == "Store")
            {
                var storeUserEntity = userEntity as StoreUserEntity;
                var storeUser       = new StoreUser
                {
                    Token    = CreateToken(storeUserEntity),
                    FullName = $"{storeUserEntity.FirstName}, {storeUserEntity.LastName}",
                    Email    = storeUserEntity.Email,
                    Role     = "Store"
                };

                if (storeUserEntity.HomeStoreId != 0)
                {
                    StoreEntity storeEntity = await _storeRepository.GetEntityAsync(storeUserEntity.HomeStoreId, ct);

                    AddressEntity addressEntity = await _addressRepository.GetEntityAsync(storeEntity.AddressId, ct);

                    Store   mappedStore = Mapper.Map <Store>(storeEntity);
                    Address address     = Mapper.Map <Address>(addressEntity);
                    mappedStore.Address = address;
                    storeUser.Store     = mappedStore;
                }
                else
                {
                    storeUser.Store = null;
                }

                var response = new ObjectResult(storeUser)
                {
                    StatusCode = (int)HttpStatusCode.OK
                };

                Request.HttpContext.Response.Headers.Add("authorization", storeUser.Token);


                return(response);
            }
            else if (rolenames[0] == "Admin")
            {
            }

            return(BadRequest(new { error = $"Could not find user with role {rolenames[0]}" }));
        }
Example #17
0
        public AddressEntity GetAddressEntityByDto(AddressModify address)
        {
            AddressEntity addressEntity = _addressRepo.findByDto(address);

            return(addressEntity == null?_addressMapper.AddressModifyToAddressEntity(address) : addressEntity);
        }
Example #18
0
 /// <summary>
 /// 增加或更新一条记录(异步方式)
 /// </summary>
 /// <param name="entity">实体模型</param>
 /// <param name="IsSave">是否增加</param>
 /// <returns></returns>
 public virtual async Task <bool> AddOrUpdateAsync(AddressEntity entity, bool IsSave)
 {
     return(IsSave ? await AddAsync(entity) : await UpdateAsync(entity));
 }
Example #19
0
 /// <summary>
 /// 增加或更新一条记录
 /// </summary>
 /// <param name="entity">实体模型</param>
 /// <param name="IsSave">是否增加</param>
 /// <returns></returns>
 public virtual bool AddOrUpdate(AddressEntity entity, bool IsSave)
 {
     return(IsSave ? Add(entity) : Update(entity));
 }
Example #20
0
        public JsonResult SaveAddress(string model)
        {
            if (string.IsNullOrEmpty(model))
            {
                return(Json(new { Type = 0, Content = "参数错误" }));
            }
            try
            {
                AddressEntity entity = JsonHelper.ToObject <AddressEntity>(model);
                entity.CountryId = base.DeliveryRegion == 1 ? "86" : "852";

                #region 参数验证
                if (entity == null)
                {
                    return(Json(new { Type = 0, Content = "参数错误" }));
                }
                if (string.IsNullOrEmpty(entity.Receiver))
                {
                    return(Json(new { Type = 0, Content = "收货人姓名为空" }));
                }
                else if (StringHelper.getLengthb(entity.Receiver) > 20)
                {
                    return(Json(new { Type = 0, Content = "收货人姓名过长" }));
                }
                if (string.IsNullOrEmpty(entity.Phone))
                {
                    return(Json(new { Type = 0, Content = "手机号码为空" }));
                }
                else
                {
                    if (!entity.Phone.IsMobilePhoneNum(entity.CountryId == (base.DeliveryRegion == 1 ? "86" : "852") ? true : false))
                    {
                        return(Json(new { Type = 0, Content = "手机号码格式不正确" }));
                    }
                }
                if (string.IsNullOrEmpty(entity.ProvinceId) ||
                    string.IsNullOrEmpty(entity.CityId) ||
                    string.IsNullOrEmpty(entity.AreaId))
                {
                    return(Json(new { Type = 0, Content = "请选择完整的省市区域" }));
                }
                if (string.IsNullOrEmpty(entity.Address))
                {
                    return(Json(new { Type = 0, Content = "详细地址为空" }));
                }
                else if (StringHelper.getLengthb(entity.Address) > 200)
                {
                    return(Json(new { Type = 0, Content = "详细地址过长" }));
                }
                if (string.IsNullOrEmpty(entity.PostCode))
                {
                    return(Json(new { Type = 0, Content = "邮政编码为空" }));
                }
                else if (!StringUtils.IsNumber(entity.PostCode, true))
                {
                    return(Json(new { Type = 0, Content = "请输入正确的邮政编码" }));
                }
                else if (StringHelper.getLengthb(entity.PostCode) != 6)
                {
                    return(Json(new { Type = 0, Content = "请输入正确的邮政编码" }));
                }
                if (entity.PapersType <= 0)
                {
                    return(Json(new { Type = 0, Content = "请选择证件类型" }));
                }
                else
                {
                    if (entity.PapersType == (int)CertificateType.IdCard)
                    {
                        if (StringHelper.getLengthb(entity.PapersCode) != 18)
                        {
                            return(Json(new { Type = 0, Content = "证件号码格式不正确" }));
                        }
                    }
                    else if (entity.PapersType == (int)CertificateType.Passport)
                    {
                        if (StringHelper.getLengthb(entity.PapersCode) > 80)
                        {
                            return(Json(new { Type = 0, Content = "证件号码格式不正确" }));
                        }
                    }
                    else if (StringHelper.getLengthb(entity.PapersCode) > 100)
                    {
                        return(Json(new { Type = 0, Content = "证件号码格式不正确" }));
                    }
                }
                #endregion

                if (entity.Id <= 0)//新增
                {
                    entity.UserId     = LoginUser.UserID;
                    entity.CreateTime = DateTime.Now;
                    entity.CreateBy   = LoginUser.UserName;
                    entity.IsEnable   = 1;

                    entity.Type = base.DeliveryRegion;
                    int addressCount = addressBll.GetUserAddressCount(LoginUser.UserID, base.DeliveryRegion);
                    if (addressCount == 20)
                    {
                        return(Json(new { Type = 0, Content = "您已经添加了20个地址,不能再添加!" }));
                    }
                    int newId = addressBll.AddAddress(entity);


                    if (newId > 0)
                    {
                        if (addressCount == 0)
                        {
                            addressBll.SetDefaultAddress(LoginUser.UserID, newId, base.DeliveryRegion);
                        }
                        return(Json(new { Type = 1, Content = "", LinkUrl = "/Buy/AddressList", aid = newId }));
                    }
                    else
                    {
                        return(Json(new { Type = 0, Content = "添加失败" }));
                    }
                }
                else //编辑
                {
                    entity.UpdateBy   = LoginUser.UserName;
                    entity.UserId     = LoginUser.UserID;
                    entity.UpdateTime = DateTime.Now;
                    if (addressBll.Edit(entity))
                    {
                        return(Json(new { Type = 1, Content = "", LinkUrl = "/Buy/AddressList" }));
                    }
                    else
                    {
                        return(Json(new { Type = 0, Content = "编辑失败" }));
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                return(Json(new { Type = 0, Content = "系统错误" }));
            }
        }
Example #21
0
 public void RemoveAddress(AddressEntity addressEntity)
 {
     this.m_personAddressesAssociation.Remove(addressEntity);
 }
 /// <summary>
 /// Patch CatalogBase type
 /// </summary>
 /// <param name="source"></param>
 /// <param name="target"></param>
 public static void Patch(this AddressEntity source, AddressEntity target)
 {
     //Nothing to do
 }
Example #23
0
        public async Task Is_Possible_To_Resolve_City()
        {
            using (var context = _serviceProvider.GetService <MyContext>())
            {
                CityImplementation cityRepository = new CityImplementation(context);
                CityEntity         city           = new CityEntity
                {
                    Name     = Faker.Address.City(),
                    IBGECode = Faker.RandomNumber.Next(1000000, 9999999),
                    StateId  = new Guid("88970a32-3a2a-4a95-8a18-2087b65f59d1")
                };

                var cityCreated = await cityRepository.InsertAsync(city);

                Assert.NotNull(cityCreated);
                Assert.Equal(city.Name, cityCreated.Name);
                Assert.Equal(city.IBGECode, cityCreated.IBGECode);
                Assert.NotNull(cityCreated.CreatedAt);
                Assert.Null(cityCreated.UpdatedAt);
                Assert.False(cityCreated.Id == Guid.Empty);

                AddressImplementation repository = new AddressImplementation(context);
                AddressEntity         entity     = new AddressEntity
                {
                    ZipCode = "99.010-030",
                    Street  = Faker.Address.StreetName(),
                    Number  = "930",
                    CityId  = city.Id
                };

                var entityCreated = await repository.InsertAsync(entity);

                Assert.NotNull(entityCreated);
                Assert.Equal(entity.ZipCode, entityCreated.ZipCode);
                Assert.Equal(entity.Street, entityCreated.Street);
                Assert.Equal(entity.Number, entityCreated.Number);
                Assert.Equal(entity.CityId, entityCreated.CityId);
                Assert.NotNull(entityCreated.CreatedAt);
                Assert.Null(entityCreated.UpdatedAt);
                Assert.False(entityCreated.Id == Guid.Empty);

                entity.Street = Faker.Address.StreetName();
                entity.Id     = entityCreated.Id;
                var entityUpdated = await repository.UpdateAsync(entity);

                Assert.NotNull(entityUpdated);
                Assert.Equal(entity.ZipCode, entityUpdated.ZipCode);
                Assert.Equal(entity.Street, entityUpdated.Street);
                Assert.Equal(entity.Number, entityUpdated.Number);
                Assert.Equal(entity.CityId, entityUpdated.CityId);
                Assert.NotNull(entityUpdated.CreatedAt);
                Assert.NotNull(entityUpdated.UpdatedAt);
                Assert.False(entityUpdated.Id == Guid.Empty);

                var entityExists = await repository.ExistsAsync(entity.Id);

                Assert.True(entityExists);

                var getEntity = await repository.SelectAsync(entity.Id);

                Assert.NotNull(getEntity);
                Assert.Equal(getEntity.ZipCode, entityUpdated.ZipCode);
                Assert.Equal(getEntity.Street, entityUpdated.Street);
                Assert.Equal(getEntity.Number, entityUpdated.Number);
                Assert.Equal(getEntity.CityId, entityUpdated.CityId);

                getEntity = await repository.SelectAsync(entity.ZipCode);

                Assert.NotNull(getEntity);
                Assert.Equal(getEntity.ZipCode, entityUpdated.ZipCode);
                Assert.Equal(getEntity.Street, entityUpdated.Street);
                Assert.Equal(getEntity.Number, entityUpdated.Number);
                Assert.Equal(getEntity.CityId, entityUpdated.CityId);
                Assert.NotNull(getEntity.City);
                Assert.Equal(city.Name, getEntity.City.Name);
                Assert.NotNull(getEntity.City.State);
                Assert.Equal("RS", getEntity.City.State.ShortName);

                var getAllEntities = await repository.SelectAsync();

                Assert.NotNull(getAllEntities);
                Assert.True(getAllEntities.Count() > 0);

                var isDeleted = await repository.DeleteAsync(getEntity.Id);

                Assert.True(isDeleted);

                getAllEntities = await repository.SelectAsync();

                Assert.NotNull(getAllEntities);
                Assert.True(getAllEntities.Count() == 0);
            }
        }
Example #24
0
		/// <summary>Po potrebi konvertira entity u business objekt.</summary>
		public static Address ConvertEntityToBusinessObject(AddressEntity entity)
		{
			Address bizobj = entity as Address;
			if (bizobj == null)
				bizobj = new Address(entity);

			return bizobj;
		}
Example #25
0
		/// <summary>Konvertira entitet u business object.</summary>
		protected Address(AddressEntity entity)
			: base(entity)
		{
		}
        public void Init()
        {
            _testGuid         = Guid.NewGuid();
            _searchRequestKey = "fileId_SequenceNumber";
            _searchRequestKeySearchNotComplete = "fileId_SequenceNumber_NotComplete";
            _exceptionSearchRequestKey         = "exception_seqNum";
            _exceptionGuid = Guid.NewGuid();
            _loggerMock    = new Mock <ILogger <PersonSearchController> >();
            _searchApiRequestServiceMock = new Mock <ISearchApiRequestService>();
            _searchResultServiceMock     = new Mock <ISearchResultService>();
            _dataPartnerServiceMock      = new Mock <IDataPartnerService>();
            _mapper       = new Mock <IMapper>();
            _registerMock = new Mock <ISearchRequestRegister>();

            _fakeSearchApiRequest = new SSG_SearchApiRequest()
            {
                SearchApiRequestId = _testGuid
            };

            var validRequestId   = Guid.NewGuid();
            var invalidRequestId = Guid.NewGuid();

            _fakeSearchApiEvent = new SSG_SearchApiEvent {
            };

            _fakePersoneIdentifier = new IdentifierEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };


            _fakePersonAddress = new AddressEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };

            _fakePersonPhoneNumber = new PhoneNumberEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };

            _fakeName = new AliasEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };

            _fakePerson = new SSG_Person
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };

            _fakeSourceIdentifier = new SSG_Identifier()
            {
                IdentifierId = Guid.NewGuid()
            };

            _fakePersonAcceptedEvent = new PersonSearchAccepted()
            {
                SearchRequestId  = Guid.NewGuid(),
                SearchRequestKey = _searchRequestKey,
                TimeStamp        = DateTime.Now,
                ProviderProfile  = new ProviderProfile()
                {
                    Name = "TEST PROVIDER"
                }
            };

            _fakePersonCompletedEvent = new PersonSearchCompleted()
            {
                SearchRequestId  = Guid.NewGuid(),
                SearchRequestKey = _searchRequestKey,
                TimeStamp        = DateTime.Now,
                ProviderProfile  = new ProviderProfile()
                {
                    Name = "TEST PROVIDER"
                },
                MatchedPersons = new List <PersonFound>()
                {
                    new PersonFound()
                    {
                        DateOfBirth = DateTime.Now,
                        FirstName   = "TEST1",
                        LastName    = "TEST2",
                        Identifiers = new List <PersonalIdentifier>()
                        {
                        },
                        Addresses = new List <Address>()
                        {
                        },
                        Phones = new List <Phone>()
                        {
                        },
                        Names = new List <Name>()
                        {
                        },
                        SourcePersonalIdentifier = new PersonalIdentifier()
                        {
                            Value = "1234567"
                        }
                    }
                }
            };

            _fakePersonFailedEvent = new PersonSearchFailed()
            {
                SearchRequestId  = Guid.NewGuid(),
                SearchRequestKey = _searchRequestKey,
                TimeStamp        = DateTime.Now,
                ProviderProfile  = new ProviderProfile()
                {
                    Name = "TEST PROVIDER"
                },
                Cause = "Unable to proceed"
            };


            _fakePersonRejectEvent = new PersonSearchRejected()
            {
                SearchRequestId  = Guid.NewGuid(),
                SearchRequestKey = _searchRequestKey,
                TimeStamp        = DateTime.Now,
                ProviderProfile  = new ProviderProfile()
                {
                    Name = "TEST PROVIDER"
                },
                Reasons = new List <ValidationResult> {
                }
            };

            _fakePersonFinalizedEvent = new PersonSearchFinalized()
            {
                SearchRequestId  = Guid.NewGuid(),
                SearchRequestKey = _searchRequestKey,
                TimeStamp        = DateTime.Now,
                Message          = "test message"
            };

            _fakePersonSubmittedEvent = new PersonSearchSubmitted()
            {
                SearchRequestId  = Guid.NewGuid(),
                SearchRequestKey = _searchRequestKey,
                TimeStamp        = DateTime.Now,
                ProviderProfile  = new ProviderProfile()
                {
                    Name = "TEST PROVIDER"
                },
                Message = "the search api request has been submitted to the Data provider."
            };

            _fakePersonInformationEvent = new PersonSearchInformation
            {
                SearchRequestId  = Guid.NewGuid(),
                SearchRequestKey = _searchRequestKey,
                TimeStamp        = DateTime.Now,
                ProviderProfile  = new ProviderProfile()
                {
                    Name = "TEST PROVIDER"
                },
                Message = "Recieved info from data provider"
            };

            _mapper.Setup(m => m.Map <SSG_SearchApiEvent>(It.IsAny <PersonSearchAccepted>()))
            .Returns(_fakeSearchApiEvent);

            _mapper.Setup(m => m.Map <SSG_SearchApiEvent>(It.IsAny <PersonSearchRejected>()))
            .Returns(_fakeSearchApiEvent);

            _mapper.Setup(m => m.Map <SSG_SearchApiEvent>(It.IsAny <PersonSearchFailed>()))
            .Returns(_fakeSearchApiEvent);

            _mapper.Setup(m => m.Map <SSG_SearchApiEvent>(It.IsAny <PersonSearchCompleted>()))
            .Returns(_fakeSearchApiEvent);

            _mapper.Setup(m => m.Map <SSG_SearchApiEvent>(It.IsAny <PersonSearchSubmitted>()))
            .Returns(_fakeSearchApiEvent);

            _mapper.Setup(m => m.Map <IdentifierEntity>(It.IsAny <PersonalIdentifier>()))
            .Returns(_fakePersoneIdentifier);

            _mapper.Setup(m => m.Map <PhoneNumberEntity>(It.IsAny <Phone>()))
            .Returns(_fakePersonPhoneNumber);

            _mapper.Setup(m => m.Map <AddressEntity>(It.IsAny <Address>()))
            .Returns(_fakePersonAddress);

            _mapper.Setup(m => m.Map <AliasEntity>(It.IsAny <Name>()))
            .Returns(_fakeName);

            _mapper.Setup(m => m.Map <SSG_Person>(It.IsAny <Person>()))
            .Returns(_fakePerson);


            _searchApiRequestServiceMock.Setup(x => x.GetLinkedSearchRequestIdAsync(It.Is <Guid>(x => x == _testGuid), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <Guid>(_testGuid));

            _searchApiRequestServiceMock.Setup(x => x.GetLinkedSearchRequestIdAsync(It.Is <Guid>(x => x == _exceptionGuid), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <Guid>(invalidRequestId));


            _searchApiRequestServiceMock.Setup(x => x.MarkComplete(It.Is <Guid>(x => x == _testGuid), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_SearchApiRequest>(new SSG_SearchApiRequest()
            {
                SearchApiRequestId = _testGuid,
                SequenceNumber     = "1234567"
            }));

            _dataPartnerServiceMock
            .Setup(x => x.GetSearchApiRequestDataProvider(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(new SSG_SearchapiRequestDataProvider {
                AdaptorName = "ICBC", SearchAPIRequestId = _testGuid, NumberOfFailures = 0, TimeBetweenRetries = 10
            }));


            _dataPartnerServiceMock
            .Setup(x => x.UpdateSearchRequestApiProvider(It.IsAny <SSG_SearchapiRequestDataProvider>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(new SSG_SearchapiRequestDataProvider {
                AdaptorName = "ICBC", SearchAPIRequestId = _testGuid, NumberOfFailures = 0, TimeBetweenRetries = 10
            }));

            _searchResultServiceMock.Setup(x => x.ProcessPersonFound(It.Is <Person>(x => x.FirstName == "TEST1"), It.IsAny <ProviderProfile>(), It.IsAny <SSG_SearchRequest>(), It.IsAny <Guid>(), It.IsAny <CancellationToken>(), It.IsAny <SSG_Identifier>()))
            .Returns(Task.FromResult <bool>(true));

            _searchApiRequestServiceMock.Setup(x => x.AddEventAsync(It.Is <Guid>(x => x == _testGuid),
                                                                    It.IsAny <SSG_SearchApiEvent>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_SearchApiEvent>(new SSG_SearchApiEvent()
            {
                Id   = _testGuid,
                Name = "Random Event"
            }));

            _searchApiRequestServiceMock.Setup(x => x.AddEventAsync(It.Is <Guid>(x => x == _exceptionGuid),
                                                                    It.IsAny <SSG_SearchApiEvent>(), It.IsAny <CancellationToken>()))
            .Throws(new Exception("random exception"));

            _registerMock.Setup(x => x.GetSearchApiRequest(It.Is <string>(m => m == _searchRequestKey)))
            .Returns(Task.FromResult(_fakeSearchApiRequest));
            _registerMock.Setup(x => x.GetSearchApiRequest(It.Is <string>(m => m == _searchRequestKeySearchNotComplete)))
            .Returns(Task.FromResult(_fakeSearchApiRequest));

            _registerMock.Setup(x => x.DataPartnerSearchIsComplete(It.Is <string>(m => m == _searchRequestKey)))
            .Returns(Task.FromResult(true));

            _registerMock.Setup(x => x.DataPartnerSearchIsComplete(It.Is <string>(m => m == _searchRequestKeySearchNotComplete)))
            .Returns(Task.FromResult(false));

            _registerMock.Setup(x => x.GetMatchedSourceIdentifier(It.IsAny <PersonalIdentifier>(), It.IsAny <Guid>()))
            .Returns(Task.FromResult(_fakeSourceIdentifier));

            _registerMock.Setup(x => x.RemoveSearchApiRequest(It.IsAny <Guid>()))
            .Returns(Task.FromResult(true));

            _sut = new PersonSearchController(_searchResultServiceMock.Object, _searchApiRequestServiceMock.Object, _dataPartnerServiceMock.Object, _loggerMock.Object, _mapper.Object, _registerMock.Object);
        }
Example #27
0
        public async Task <IActionResult> EditUserAddressAsync(int userId, int addressId, AddressEntity address)
        {
            //if (_addressService.CheckIfAddressSupplierExist(supplierId))
            //{
            var model = await _addressService.EditUserAddressAsync(userId, addressId, address);

            var location = _linkGanarator.GetPathByAction("GetUserAddressByIdAsync", "Users", new { userId, addressId });

            return(Created(location, model));

            //else
            //{
            //    return BadRequest("Suppliers does not exist");
            //}
        }
 public AddressEntity CreateCompanyAddress(int companyId, AddressEntity address)
 {
     return(_repository.CreateCompanyAddress(companyId, address));
 }
Example #29
0
 public void Update(AddressEntity addressEntity)
 {
     addressdal.Update(addressEntity);
 }
Example #30
0
 private static PropertyEntity Map(PropertyEntity property, AddressEntity address, Marker marker, FileEntity file, PropertyBranch branch)
 {
     return(Map <PropertyEntity>(property, address, marker, file, branch));
 }
        public MResult <int> SetAddress(string sid, string token, string guid, string user_id, string uid, AddressEntity address)
        {
            var result = new MResult <int>();

            try
            {
                result = MemberBLL.SetAddress(sid, token, UserId, uid, address);
            }
            catch (Exception)
            {
                result.status = MResultStatus.ExceptionError;
                result.msg    = "处理数据出错!";
            }

            return(result);
        }
Example #32
0
 public void SetFrom(AddressEntity from)
 {
     this.Entity.From = from;
 }
Example #33
0
 public ConsumableDemandEntity Build(AddressEntity a)
 {
     NullCheck.ThrowIfNull <AddressEntity>(a);
     return(this);
 }
Example #34
0
 public int Insert(AddressEntity addressEntity)
 {
     return(addressdal.Insert(addressEntity));
 }
Example #35
0
 /// <summary>
 /// constructor where we pass the object we want to insert
 /// </summary>
 /// <param name="entity"></param>
 public AddAddressCommand(ref AddressEntity entity)
 => _entity = entity;
Example #36
0
        public void Init()
        {
            _loggerMock = new Mock <ILogger <SearchResultService> >();
            _searchRequestServiceMock = new Mock <ISearchRequestService>();
            _mapper = new Mock <IMapper>();
            var validRequestId = Guid.NewGuid();

            var validVehicleId         = Guid.NewGuid();
            var validOtherAssetId      = Guid.NewGuid();
            var validBankInformationId = Guid.NewGuid();
            var validEmploymentId      = Guid.NewGuid();

            _fakePersoneIdentifier = new IdentifierEntity
            {
                Identification = "1234567",
                SearchRequest  = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };

            _fakeSourceIdentifier = new SSG_Identifier
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };

            _fakePersonAddress = new AddressEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                },
                AddressLine1 = "addressLine1"
            };
            _fakeEmployment = new EmploymentEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };

            _fakeEmploymentContact = new EmploymentContactEntity
            {
                PhoneNumber = "11111111"
            };

            _fakePersonPhoneNumber = new PhoneNumberEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };

            _fakeRelatedPerson = new RelatedPersonEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };

            _fakeName = new AliasEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };

            _ssg_fakePerson = new PersonEntity
            {
            };

            _searchRequest = new SSG_SearchRequest
            {
                SearchRequestId = validRequestId
            };

            _fakeBankInfo = new BankingInformationEntity
            {
                BankName = "bank"
            };

            _fakeVehicleEntity = new VehicleEntity
            {
                SearchRequest = _searchRequest,
                PlateNumber   = "AAA.BBB"
            };

            _fakeAssetOwner = new SSG_AssetOwner()
            {
                OrganizationName = "Ford Inc."
            };

            _fakeOtherAsset = new AssetOtherEntity()
            {
                SearchRequest   = _searchRequest,
                TypeDescription = "type description"
            };

            _fakeWorkSafeBcClaim = new CompensationClaimEntity()
            {
                SearchRequest      = _searchRequest,
                ClaimNumber        = "claimNumber",
                BankingInformation = new SSG_Asset_BankingInformation()
                {
                    BankingInformationId = validBankInformationId
                },
                Employment = new SSG_Employment()
                {
                    EmploymentId = validEmploymentId
                }
            };

            _fakeCompensationEmployment = new EmploymentEntity()
            {
                BusinessName = COMPENSATION_BUISNESS_NAME
            };

            _fakeIcbcClaim = new ICBCClaimEntity()
            {
                ClaimNumber = "icbcClaimNumber"
            };

            _fakeInvolvedParty = new SSG_InvolvedParty()
            {
                OrganizationName = "name"
            };

            _fakeSimplePhone = new SSG_SimplePhoneNumber()
            {
                PhoneNumber = "0"
            };

            _fakePerson = new Person()
            {
                DateOfBirth = DateTime.Now,
                FirstName   = "TEST1",
                LastName    = "TEST2",
                Identifiers = new List <PersonalIdentifier>()
                {
                    new PersonalIdentifier()
                    {
                        Value    = "test",
                        IssuedBy = "test",
                        Type     = PersonalIdentifierType.BCDriverLicense
                    }
                },
                Addresses = new List <Address>()
                {
                    new Address()
                    {
                        AddressLine1   = "AddressLine1",
                        AddressLine2   = "AddressLine2",
                        AddressLine3   = "AddressLine3",
                        StateProvince  = "Manitoba",
                        City           = "testCity",
                        Type           = "residence",
                        CountryRegion  = "canada",
                        ZipPostalCode  = "p3p3p3",
                        ReferenceDates = new List <ReferenceDate>()
                        {
                            new ReferenceDate()
                            {
                                Index = 0, Key = "Start Date", Value = new DateTime(2019, 9, 1)
                            },
                            new ReferenceDate()
                            {
                                Index = 1, Key = "End Date", Value = new DateTime(2020, 9, 1)
                            }
                        },
                        Description = "description"
                    }
                },
                Phones = new List <Phone>()
                {
                    new Phone()
                    {
                        PhoneNumber = "4005678900"
                    }
                },
                Names = new List <Name>()
                {
                    new Name()
                    {
                        FirstName = "firstName"
                    }
                },
                RelatedPersons = new List <RelatedPerson>()
                {
                    new RelatedPerson()
                    {
                        FirstName = "firstName"
                    }
                },

                Employments = new List <Employment>()
                {
                    new Employment()
                    {
                        Occupation = "Occupation",
                        Employer   = new Employer()
                        {
                            Phones = new List <Phone>()
                            {
                                new Phone()
                                {
                                    PhoneNumber = "1111111", Type = "Phone"
                                }
                            }
                        }
                    }
                },

                BankInfos = new List <BankInfo>()
                {
                    new BankInfo()
                    {
                        BankName = "BankName",
                    }
                },
                Vehicles = new List <Vehicle>()
                {
                    new Vehicle()
                    {
                    },
                    new Vehicle()
                    {
                        Owners = new List <InvolvedParty>()
                        {
                            new InvolvedParty()
                            {
                            }
                        }
                    }
                },
                OtherAssets = new List <OtherAsset>()
                {
                    new OtherAsset()
                    {
                        Owners = new List <InvolvedParty>()
                        {
                            new InvolvedParty()
                            {
                            }
                        }
                    }
                },
                CompensationClaims = new List <CompensationClaim>()
                {
                    new CompensationClaim()
                    {
                        ClaimNumber = "claimNumber",
                        BankInfo    = new BankInfo()
                        {
                            BankName = "compensationBankName"
                        },
                        Employer = new Employer()
                        {
                            Name = COMPENSATION_BUISNESS_NAME
                        },
                        ReferenceDates = new ReferenceDate[]
                        {
                            new ReferenceDate()
                            {
                                Index = 0, Key = "Start Date", Value = new DateTime(2019, 9, 1)
                            }
                        }
                    }
                },
                InsuranceClaims = new List <InsuranceClaim>()
                {
                    new InsuranceClaim()
                    {
                        ClaimNumber    = "icbcClaimNumber",
                        InsuredParties = new List <InvolvedParty>()
                        {
                            new InvolvedParty()
                            {
                                Organization = "insuranceClaimOrg"
                            }
                        },
                        ClaimCentre = new ClaimCentre()
                        {
                            ContactNumber = new List <Phone>()
                            {
                                new Phone()
                                {
                                    PhoneNumber = "9999"
                                }
                            }
                        }
                    }
                }
            };

            _providerProfile = new ProviderProfile()
            {
                Name = "Other"
            };


            _fakeToken = new CancellationToken();

            _mapper.Setup(m => m.Map <IdentifierEntity>(It.IsAny <PersonalIdentifier>()))
            .Returns(_fakePersoneIdentifier);

            _mapper.Setup(m => m.Map <PhoneNumberEntity>(It.IsAny <Phone>()))
            .Returns(_fakePersonPhoneNumber);

            _mapper.Setup(m => m.Map <AddressEntity>(It.IsAny <Address>()))
            .Returns(_fakePersonAddress);

            _mapper.Setup(m => m.Map <AliasEntity>(It.IsAny <Name>()))
            .Returns(_fakeName);

            _mapper.Setup(m => m.Map <PersonEntity>(It.IsAny <Person>()))
            .Returns(_ssg_fakePerson);

            _mapper.Setup(m => m.Map <EmploymentEntity>(It.Is <Employer>(m => m.Name == COMPENSATION_BUISNESS_NAME)))
            .Returns(_fakeCompensationEmployment);

            _mapper.Setup(m => m.Map <EmploymentEntity>(It.IsAny <Employment>()))
            .Returns(_fakeEmployment);

            _mapper.Setup(m => m.Map <EmploymentContactEntity>(It.IsAny <Phone>()))
            .Returns(_fakeEmploymentContact);

            _mapper.Setup(m => m.Map <RelatedPersonEntity>(It.IsAny <RelatedPerson>()))
            .Returns(_fakeRelatedPerson);

            _mapper.Setup(m => m.Map <BankingInformationEntity>(It.IsAny <BankInfo>()))
            .Returns(_fakeBankInfo);

            _mapper.Setup(m => m.Map <VehicleEntity>(It.IsAny <Vehicle>()))
            .Returns(_fakeVehicleEntity);

            _mapper.Setup(m => m.Map <AssetOwnerEntity>(It.IsAny <InvolvedParty>()))
            .Returns(_fakeAssetOwner);

            _mapper.Setup(m => m.Map <AssetOtherEntity>(It.IsAny <OtherAsset>()))
            .Returns(_fakeOtherAsset);

            _mapper.Setup(m => m.Map <CompensationClaimEntity>(It.IsAny <CompensationClaim>()))
            .Returns(_fakeWorkSafeBcClaim);

            _mapper.Setup(m => m.Map <ICBCClaimEntity>(It.IsAny <InsuranceClaim>()))
            .Returns(_fakeIcbcClaim);

            _mapper.Setup(m => m.Map <InvolvedPartyEntity>(It.Is <InvolvedParty>(m => m.Organization == "insuranceClaimOrg")))
            .Returns(_fakeInvolvedParty);

            _mapper.Setup(m => m.Map <SimplePhoneNumberEntity>(It.Is <Phone>(m => m.PhoneNumber == "9999")))
            .Returns(_fakeSimplePhone);

            _searchRequestServiceMock.Setup(x => x.CreateIdentifier(It.IsAny <IdentifierEntity>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Identifier>(new SSG_Identifier()
            {
            }));

            _searchRequestServiceMock.Setup(x => x.CreateAddress(It.Is <AddressEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Address>(new SSG_Address()
            {
                AddressLine1 = "test full line"
            }));

            _searchRequestServiceMock.Setup(x => x.CreatePhoneNumber(It.Is <PhoneNumberEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_PhoneNumber>(new SSG_PhoneNumber()
            {
                TelePhoneNumber = "4007678231"
            }));

            _searchRequestServiceMock.Setup(x => x.CreateName(It.Is <AliasEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Aliase>(new SSG_Aliase()
            {
                FirstName = "firstName"
            }));

            _searchRequestServiceMock.Setup(x => x.SavePerson(It.Is <PersonEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Person>(new SSG_Person()
            {
                FirstName = "First"
            }));

            _searchRequestServiceMock.Setup(x => x.CreateEmployment(It.Is <EmploymentEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Employment>(new SSG_Employment()
            {
                EmploymentId = Guid.NewGuid(),
                Occupation   = "Occupation"
            }));

            _searchRequestServiceMock.Setup(x => x.CreateEmploymentContact(It.IsAny <EmploymentContactEntity>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_EmploymentContact>(new SSG_EmploymentContact()
            {
                PhoneNumber = "4007678231"
            }));

            _searchRequestServiceMock.Setup(x => x.CreateRelatedPerson(It.Is <RelatedPersonEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Identity>(new SSG_Identity()
            {
                FirstName = "firstName"
            }));

            _searchRequestServiceMock.Setup(x => x.CreateBankInfo(It.Is <BankingInformationEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Asset_BankingInformation>(new SSG_Asset_BankingInformation()
            {
                BankingInformationId = validBankInformationId,
                BankName             = "bankName"
            }));

            _searchRequestServiceMock.Setup(x => x.CreateVehicle(It.Is <VehicleEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Asset_Vehicle>(new SSG_Asset_Vehicle()
            {
                VehicleId = validVehicleId
            }));

            _searchRequestServiceMock.Setup(x => x.CreateAssetOwner(It.Is <SSG_AssetOwner>(x => x.Vehicle.VehicleId == validVehicleId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_AssetOwner>(new SSG_AssetOwner()
            {
                Type = "Owner"
            }));

            _searchRequestServiceMock.Setup(x => x.CreateOtherAsset(It.Is <AssetOtherEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Asset_Other>(new SSG_Asset_Other()
            {
                AssetOtherId = validOtherAssetId
            }));

            _searchRequestServiceMock.Setup(x => x.CreateCompensationClaim(It.Is <CompensationClaimEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Asset_WorkSafeBcClaim>(new SSG_Asset_WorkSafeBcClaim()
            {
                ClaimNumber = "claimNumber"
            }));

            _searchRequestServiceMock.Setup(x => x.CreateEmployment(It.Is <EmploymentEntity>(x => x.BusinessName == COMPENSATION_BUISNESS_NAME && x.Date1 == new DateTime(2019, 9, 1)), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Employment>(new SSG_Employment()
            {
                EmploymentId = Guid.NewGuid(),
            }));

            _searchRequestServiceMock.Setup(x => x.CreateInsuranceClaim(It.Is <ICBCClaimEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Asset_ICBCClaim>(new SSG_Asset_ICBCClaim()
            {
                ICBCClaimId = Guid.NewGuid()
            }));

            _searchRequestServiceMock.Setup(x => x.CreateInvolvedParty(It.IsAny <SSG_InvolvedParty>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_InvolvedParty>(new SSG_InvolvedParty()
            {
            }));

            _searchRequestServiceMock.Setup(x => x.CreateSimplePhoneNumber(It.IsAny <SSG_SimplePhoneNumber>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_SimplePhoneNumber>(new SSG_SimplePhoneNumber()
            {
            }));

            _searchRequestServiceMock.Setup(x => x.CreateTransaction(It.IsAny <SSG_SearchRequestResultTransaction>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_SearchRequestResultTransaction>(new SSG_SearchRequestResultTransaction()
            {
            }));

            _sut = new SearchResultService(_searchRequestServiceMock.Object, _loggerMock.Object, _mapper.Object);
        }
Example #37
0
 public CompanyEntity(int id, string name, string cnpj, string website, string email, bool isActive, AddressEntity address)
 {
     Id           = id;
     Name         = name;
     Cnpj         = cnpj;
     WebSite      = website;
     Email        = email;
     IsActive     = isActive;
     CreationDate = DateTime.Now;
     LastUpdate   = DateTime.Now;
     Address      = address;
 }