public void TestGetEntiyByPK(Int32 pkid)
 {
     var _AddressBO = new AddressBO(new FakeAddressConverter());
     var dtoEntity=new AddressDto(){AddressID=pkid};
     var dbResult = _AddressBO.GetEntiyByPK(dtoEntity);
     Assert.NotNull(dbResult);
 }
 //Update PUT: Address/Put/
 public async Task<bool> Put(AddressDto value)
 {
     if (ModelState.IsValid)
     {
        return await  ClientHTTPPut<AddressDto>(value);
     }
     return false;
 }
        public void TestFindEnties(AddressDto _AddressDto)
        {
            var _AddressBO = new AddressBO(new AddressConverter());
		    bool hasAdded = _AddressBO.CreateEntiy(_AddressDto);
            var dbResult=_AddressBO.FindEnties(new PagedList<AddressDto> {_AddressDto});
            Assert.NotNull(dbResult);
			Assert.True(dbResult.Total>0);
        }
 // Add POST: Address/Post
 public async Task<bool> Post(AddressDto value) 
 {
     if (ModelState.IsValid)
     {
       return await ClientInvokeHttpPOST<AddressDto>(value);
     }
     return false;
 }
Пример #5
0
  /// <summary>
  /// Converts the dto to entities.
  /// </summary>
  /// <param name="_AddressDto">The Address dto</param>
  /// <param name="efAddress">已存在的Address EF model</param>
  /// <returns>Address</returns>
 public Address ConvertDtoToEntities(AddressDto _AddressDto, Address efAddress)
 {
      if (_AddressDto==null && efAddress==null)
      {
           throw new ArgumentNullException("models should not be null");
      }
       ConvertObject(_AddressDto, efAddress);
       return efAddress;
 }
Пример #6
0
          /// <summary>
          /// Converts the dto to entities.
          /// </summary>
          /// <param name="_ AddressDto">The  Address dto.</param>
          /// <param name="ef Address">已存的EntityFramework实体 ef Address</param>
          /// <param name="skipNullPropertyValue">if set to <c>true</c> [skip null property value].</param>
          /// <returns>Address</returns>
        public Address ConvertDtoToEntities(AddressDto _AddressDto, Address efAddress, bool skipNullPropertyValue)
        {
               if (_AddressDto==null && efAddress==null)
               {
                    throw new ArgumentNullException("models should not be null");
               }
 
              ConvertObjectWithCheckNull(_AddressDto, skipNullPropertyValue, efAddress);
              return efAddress;
        }
        // GET: Address/Find/?pageindex=1&pagesize=10&....
        public async Task<JsonResult> Find(AddressDto _AddressDto,int pageIndex=1,int pageSize=10)
        {
          string pageQueryString = string.Empty;
           //for EASYUI datagrid
           if (Request["page"] != null)
           {
               pageIndex = Convert.ToInt32(Request["page"].ToString());
           }
		    pageQueryString = string.Format("&pageIndex={0}&pageSize={1}", pageIndex, pageSize);
           return Json(await ClientHTTPGetList<EasyuiDatagridData<AddressDto>, AddressDto>(_AddressDto, pageQueryString));
        }
Пример #8
0
         /// <summary>
        /// Update With Attach the AddressEntiy.
        /// </summary>
        /// <param name="Entiy">The Entiy.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</return
        public bool UpdateWithAttachEntiy(AddressDto t)
        {
            var dbentity = typeAdapter.ConvertDtoToEntities(t);
            if (StateHelpers.GetEquivalentEntityState(dbentity.State)==StateHelpers.GetEquivalentEntityState(State.Detached))
            {
               entiesrepository.Attach(dbentity); 
            }

            dbentity.State = State.Modified;
            context.ChangeObjectState<Address>(dbentity,  StateHelpers.GetEquivalentEntityState(dbentity.State));

            uow.Save();
            return true;
        }
Пример #9
0
 /// <summary>
 /// Dels the With Attach Entiy.
 /// </summary>
 /// <param name="Entiy">The Entiy.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
 public bool DeleteEntiy(AddressDto t)
 {
     var dbEntity = typeAdapter.ConvertDtoToEntities(t);
     entiesrepository.Delete(dbEntity);
     entiesrepository.Save();
     return true;
 }
 /// <summary>
 /// Gets the specified identifier.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <example><code>GET: api/Address/5</code></example>
 /// <returns>AddressDto</returns>
 public AddressDto Get(Int32 id)
 {
     var dtoEntity = new AddressDto() { AddressID=id};
     return _AddressBO.GetEntiyByPK(dtoEntity);
 }
 public bool Put(AddressDto value)
 {
     return _AddressBO.UpdateWithAttachEntiy(value);
 }
 // DELETE: api/Address/5
 public void Delete(int id)
 {
     var entity = new AddressDto() { AddressID = id };
     _AddressBO.DeleteWithAttachEntiy(entity);
 }
Пример #13
0
 public Address ConvertDtoToEntities(AddressDto _AddressDto, Address efAddress)
 {
     return new Address();
 }
Пример #14
0
        /// <summary>
        /// Updates the entiy asynchronous.
        /// </summary>
        /// <param name="tDTo">The t d to.</param>
        /// <returns></returns>
        public async Task<int> UpdateEntiyAsync(AddressDto tDTo)
        {
            var dbentity = typeAdapter.ConvertDtoToEntities(tDTo);
            dbentity.State = State.Modified;
            context.ChangeObjectState<Address>(dbentity, StateHelpers.GetEquivalentEntityState(dbentity.State));

            return await uow.SaveAsync();
        }
Пример #15
0
   private static void ConvertObjectWithCheckNull(AddressDto _AddressDto, bool skipNullPropertyValue, Address efAddress)
   {
        efAddress.AddressID=_AddressDto.AddressID;
   
        if (!skipNullPropertyValue ||  _AddressDto.AddressLine1 != null) {efAddress.AddressLine1=_AddressDto.AddressLine1; }
 
        if (!skipNullPropertyValue ||  _AddressDto.AddressLine2 != null) {efAddress.AddressLine2=_AddressDto.AddressLine2; }
 
        if (!skipNullPropertyValue ||  _AddressDto.City != null) {efAddress.City=_AddressDto.City; }
           efAddress.StateProvinceID=_AddressDto.StateProvinceID;
   
        if (!skipNullPropertyValue ||  _AddressDto.PostalCode != null) {efAddress.PostalCode=_AddressDto.PostalCode; }
           efAddress.rowguid=_AddressDto.rowguid;
             efAddress.ModifiedDate=_AddressDto.ModifiedDate;
  
     }
Пример #16
0
 public Address ConvertDtoToEntities(AddressDto _AddressDto, Address efAddress, bool skipNullPropertyValue)
 {
     return new Address();
 }
Пример #17
0
         /// <summary>
        /// Update  the AddressEntiy.
        /// </summary>
        /// <param name="Entiy">The Entiy.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</return
        public bool UpdateEntiy(AddressDto t)
        {
            var dbentity = typeAdapter.ConvertDtoToEntities(t);
            dbentity.State = State.Modified;
            context.ChangeObjectState<Address>(dbentity,  StateHelpers.GetEquivalentEntityState(dbentity.State));

            uow.Save();
            return true;
        }
Пример #18
0
 /// <summary>
 /// Updates the entiy with get asynchronous.
 /// </summary>
 /// <param name="entity">The entity.</param>
 /// <returns></returns>
 public async Task<int> UpdateEntiyWithGetAsync(AddressDto entity)
 {
     var dbEntity = entiesrepository.Repository.Single(e => e.AddressID == entity.AddressID);
     dbEntity = typeAdapter.ConvertDtoToEntities(entity, dbEntity, skipNullPropertyValue: true);
     return await uow.SaveAsync();
 }
Пример #19
0
 /// <summary>
 /// Updates the Addressentiy with get.
 /// </summary>
 /// <param name="t">The t.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</return>
 public bool UpdateEntiyWithGet(AddressDto entity)
 {
     var dbEntity = entiesrepository.Repository.Single(e => e.AddressID == entity.AddressID);
     dbEntity = typeAdapter.ConvertDtoToEntities(entity,dbEntity,skipNullPropertyValue:true);
     uow.Save();
     return true;
 }
Пример #20
0
 private static void ConvertObject(AddressDto _AddressDto, Address efAddress)
 {
     efAddress.AddressID=_AddressDto.AddressID; 
        efAddress.AddressLine1=_AddressDto.AddressLine1; 
        efAddress.AddressLine2=_AddressDto.AddressLine2; 
        efAddress.City=_AddressDto.City; 
        efAddress.StateProvinceID=_AddressDto.StateProvinceID; 
        efAddress.PostalCode=_AddressDto.PostalCode; 
        efAddress.rowguid=_AddressDto.rowguid; 
        efAddress.ModifiedDate=_AddressDto.ModifiedDate; 
    }
Пример #21
0
        /// <summary>
        /// Updates the with attach entiy asynchronous.
        /// </summary>
        /// <param name="tDTo">The t d to.</param>
        /// <returns></returns>
        public async Task<int> UpdateWithAttachEntiyAsync(AddressDto tDTo)
        {
            var dbentity = typeAdapter.ConvertDtoToEntities(tDTo);
            if (StateHelpers.GetEquivalentEntityState(dbentity.State) == StateHelpers.GetEquivalentEntityState(State.Detached))
            {
                entiesrepository.Attach(dbentity);
            }

            dbentity.State = State.Modified;
            context.ChangeObjectState<Address>(dbentity, StateHelpers.GetEquivalentEntityState(dbentity.State));

            return await uow.SaveAsync();
        }
Пример #22
0
        /// <summary>
        /// Builds all query.
        /// </summary>
        /// <param name="_Address">The Address dto.</param>
        /// <returns></returns>
        private static  Expression<Func<Address, bool>> BuildAllQuery(AddressDto _addressDto)
       { 
           var list = new List<Expression<Func<Address, bool>>>();

                if (_addressDto.AddressID > 0) list.Add(c => c.AddressID == _addressDto.AddressID);
    if (!string.IsNullOrEmpty(_addressDto.AddressLine1)) list.Add(c => c.AddressLine1.Contains(_addressDto.AddressLine1));
    if (!string.IsNullOrEmpty(_addressDto.AddressLine2)) list.Add(c => c.AddressLine2.Contains(_addressDto.AddressLine2));
    if (!string.IsNullOrEmpty(_addressDto.City)) list.Add(c => c.City.Contains(_addressDto.City));
    if (_addressDto.StateProvinceID > 0) list.Add(c => c.StateProvinceID == _addressDto.StateProvinceID);
    if (!string.IsNullOrEmpty(_addressDto.PostalCode)) list.Add(c => c.PostalCode.Contains(_addressDto.PostalCode));
    
    
          //Add more condition
            Expression<Func<Address, bool>> entityQueryConditionTotal = null;
            foreach (var e in list)
            {
                entityQueryConditionTotal= entityQueryConditionTotal == null ? e : entityQueryConditionTotal.And(e);

            }
            return entityQueryConditionTotal;
       }
 public void Put(AddressDto value)
 {
     _AddressBO.UpdateWithAttachEntiy(value);
 }
Пример #24
0
 /// <summary>
 /// Creates the entiy asynchronous.
 /// </summary>
 /// <param name="t">The t.</param>
 /// <returns></returns>
 public async Task<int> CreateEntiyAsync(AddressDto tDTo)
 {
     var dbEntity = typeAdapter.ConvertDtoToEntities(tDTo);
     entiesrepository.Add(dbEntity);
     return await entiesrepository.SaveAsync();
 }
 public void Post(AddressDto value)
 {
     _AddressBO.CreateEntiy(value);
 }
Пример #26
0
 /// <summary>
 /// Gets the Entiy
 /// </summary>
 /// <param name="pid">The pid.</param>
 /// <returns>Entiy</returns>
 public AddressDto GetEntiyByPK(AddressDto tDTo)
 {
     var entity=entiesrepository.Repository.Single(e => e.AddressID == tDTo.AddressID);
     return typeAdapter.ConvertEntitiesToDto(entity);
  
 }
 // DELETE: api/Address/5
 public bool Delete(int id)
 {
     var entity = new AddressDto() { AddressID = id };
     return _AddressBO.DeleteWithAttachEntiy(entity);
 }
Пример #28
0
 /// <summary>
 /// Deletes the with attach entiy asynchronous.
 /// </summary>
 /// <param name="t">The t.</param>
 /// <returns></returns>
 public async Task<int> DeleteWithAttachEntiyAsync(AddressDto tDTo)
 {
     var dbEntity = typeAdapter.ConvertDtoToEntities(tDTo);
     entiesrepository.Attach(dbEntity);
     entiesrepository.Delete(dbEntity);
     return await entiesrepository.SaveAsync();
 }
 public bool Post(AddressDto value)
 {
     return _AddressBO.CreateEntiy(value);
 }
Пример #30
0
 /// <summary>
 /// The del entiy.
 /// </summary>
 /// <param name="entities"></param>
 /// <returns>
 /// The <see cref="bool" />.
 /// </returns>
 public bool DeleteWithAttachEntiy(AddressDto[] entities)
 {
     bool flag = false;
    if (entities!=null& entities.Length>0)
    {
        foreach(var entity in entities)
        {
            flag=DeleteWithAttachEntiy(entity);
        }
    }
    return flag;
 }