コード例 #1
0
 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);
 }
コード例 #2
0
 //Update PUT: Address/Put/
 public async Task<bool> Put(AddressDto value)
 {
     if (ModelState.IsValid)
     {
        return await  ClientHTTPPut<AddressDto>(value);
     }
     return false;
 }
コード例 #3
0
        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);
        }
コード例 #4
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;
        }
コード例 #7
0
        // 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;
 }
コード例 #10
0
 /// <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);
 }
コード例 #11
0
 public bool Put(AddressDto value)
 {
     return _AddressBO.UpdateWithAttachEntiy(value);
 }
コード例 #12
0
 // 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;
       }
コード例 #23
0
 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();
 }
コード例 #25
0
 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);
  
 }
コード例 #27
0
 // 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();
 }
コード例 #29
0
 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;
 }