public void TestUpdateEntiyWithGet(EmployeePayHistoryDto _EmployeePayHistoryDto) { var _EmployeePayHistoryBO = new EmployeePayHistoryBO(new FakeEmployeePayHistoryConverter()); var dbResult = _EmployeePayHistoryBO.UpdateEntiyWithGet(_EmployeePayHistoryDto); Assert.NotNull(dbResult); }
public void TestUpdateWithAttachEntiy(EmployeePayHistoryDto _EmployeePayHistoryDto) { var _EmployeePayHistoryBO = new EmployeePayHistoryBO(new FakeEmployeePayHistoryConverter()); bool isUpdated = _EmployeePayHistoryBO.UpdateWithAttachEntiy(_EmployeePayHistoryDto); Assert.True(isUpdated); }
/// <summary> /// Updates the entiy with get asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task <int> UpdateEntiyWithGetAsync(EmployeePayHistoryDto entity) { var dbEntity = entiesrepository.Repository.Single(e => e.EmployeeID == entity.EmployeeID); dbEntity = typeAdapter.ConvertDtoToEntities(entity, dbEntity, skipNullPropertyValue: true); return(await uow.SaveAsync()); }
public void TestAdd(EmployeePayHistoryDto _EmployeePayHistoryDto) { var _EmployeePayHistoryBO = new EmployeePayHistoryBO(new FakeEmployeePayHistoryConverter()); bool hasAdded = _EmployeePayHistoryBO.CreateEntiy(_EmployeePayHistoryDto); Assert.True(hasAdded); }
/// <summary> /// Creates the entiy asynchronous. /// </summary> /// <param name="t">The t.</param> /// <returns></returns> public async Task <int> CreateEntiyAsync(EmployeePayHistoryDto tDTo) { var dbEntity = typeAdapter.ConvertDtoToEntities(tDTo); entiesrepository.Add(dbEntity); return(await entiesrepository.SaveAsync()); }
public void TestDeleteEntiy(EmployeePayHistoryDto _EmployeePayHistoryDto) { var _EmployeePayHistoryBO = new EmployeePayHistoryBO(new FakeEmployeePayHistoryConverter()); bool isDeleted = _EmployeePayHistoryBO.DeleteEntiy(_EmployeePayHistoryDto); Assert.True(isDeleted); }
private static void ConvertObjectWithCheckNull(EmployeePayHistoryDto _EmployeePayHistoryDto, bool skipNullPropertyValue, EmployeePayHistory efEmployeePayHistory) { efEmployeePayHistory.EmployeeID = _EmployeePayHistoryDto.EmployeeID; efEmployeePayHistory.RateChangeDate = _EmployeePayHistoryDto.RateChangeDate; efEmployeePayHistory.Rate = _EmployeePayHistoryDto.Rate; efEmployeePayHistory.PayFrequency = _EmployeePayHistoryDto.PayFrequency; efEmployeePayHistory.ModifiedDate = _EmployeePayHistoryDto.ModifiedDate; }
private static void ConvertObject(EmployeePayHistoryDto _EmployeePayHistoryDto, EmployeePayHistory efEmployeePayHistory) { efEmployeePayHistory.EmployeeID = _EmployeePayHistoryDto.EmployeeID; efEmployeePayHistory.RateChangeDate = _EmployeePayHistoryDto.RateChangeDate; efEmployeePayHistory.Rate = _EmployeePayHistoryDto.Rate; efEmployeePayHistory.PayFrequency = _EmployeePayHistoryDto.PayFrequency; efEmployeePayHistory.ModifiedDate = _EmployeePayHistoryDto.ModifiedDate; }
//Update PUT: EmployeePayHistory/Put/ public async Task <bool> Put(EmployeePayHistoryDto value) { if (ModelState.IsValid) { return(await ClientHTTPPut <EmployeePayHistoryDto>(value)); } return(false); }
/// <summary> /// Deletes the with attach entiy asynchronous. /// </summary> /// <param name="t">The t.</param> /// <returns></returns> public async Task <int> DeleteWithAttachEntiyAsync(EmployeePayHistoryDto tDTo) { var dbEntity = typeAdapter.ConvertDtoToEntities(tDTo); entiesrepository.Attach(dbEntity); entiesrepository.Delete(dbEntity); return(await entiesrepository.SaveAsync()); }
/// <summary> /// Updates the EmployeePayHistoryentiy with get. /// </summary> /// <param name="t">The t.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</return> public bool UpdateEntiyWithGet(EmployeePayHistoryDto entity) { var dbEntity = entiesrepository.Repository.Single(e => e.EmployeeID == entity.EmployeeID); dbEntity = typeAdapter.ConvertDtoToEntities(entity, dbEntity, skipNullPropertyValue: true); uow.Save(); return(true); }
// Add POST: EmployeePayHistory/Post public async Task <bool> Post(EmployeePayHistoryDto value) { if (ModelState.IsValid) { return(await ClientInvokeHttpPOST <EmployeePayHistoryDto>(value)); } return(false); }
/// <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(EmployeePayHistoryDto t) { var dbEntity = typeAdapter.ConvertDtoToEntities(t); entiesrepository.Delete(dbEntity); entiesrepository.Save(); return(true); }
/// <summary> /// Updates the entiy asynchronous. /// </summary> /// <param name="tDTo">The t d to.</param> /// <returns></returns> public async Task <int> UpdateEntiyAsync(EmployeePayHistoryDto tDTo) { var dbentity = typeAdapter.ConvertDtoToEntities(tDTo); dbentity.State = State.Modified; context.ChangeObjectState <EmployeePayHistory>(dbentity, StateHelpers.GetEquivalentEntityState(dbentity.State)); return(await uow.SaveAsync()); }
// DELETE: api/EmployeePayHistory/5 public bool Delete(int id) { var entity = new EmployeePayHistoryDto() { EmployeeID = id }; return(_EmployeePayHistoryBO.DeleteWithAttachEntiy(entity)); }
/// <summary> /// Converts the dto to entities. /// </summary> /// <param name="_EmployeePayHistoryDto">The EmployeePayHistory dto</param> /// <param name="efEmployeePayHistory">已存在的EmployeePayHistory EF model</param> /// <returns>EmployeePayHistory</returns> public EmployeePayHistory ConvertDtoToEntities(EmployeePayHistoryDto _EmployeePayHistoryDto, EmployeePayHistory efEmployeePayHistory) { if (_EmployeePayHistoryDto == null && efEmployeePayHistory == null) { throw new ArgumentNullException("models should not be null"); } ConvertObject(_EmployeePayHistoryDto, efEmployeePayHistory); return(efEmployeePayHistory); }
/// <summary> /// Gets the specified identifier. /// </summary> /// <param name="id">The identifier.</param> /// <example><code>GET: api/EmployeePayHistory/5</code></example> /// <returns>EmployeePayHistoryDto</returns> public EmployeePayHistoryDto Get(Int32 id) { var dtoEntity = new EmployeePayHistoryDto() { EmployeeID = id }; return(_EmployeePayHistoryBO.GetEntiyByPK(dtoEntity)); }
public void TestFindEntiesWithSimplePaging(EmployeePayHistoryDto _EmployeePayHistoryDto) { var _EmployeePayHistoryBO = new EmployeePayHistoryBO(new EmployeePayHistoryConverter()); bool hasAdded = _EmployeePayHistoryBO.CreateEntiy(_EmployeePayHistoryDto); var dbResult = _EmployeePayHistoryBO.FindEnties(1, 10); Assert.NotNull(dbResult); Assert.True(dbResult.Count > 0); }
/// <summary> /// Update the EmployeePayHistoryEntiy. /// </summary> /// <param name="Entiy">The Entiy.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</return public bool UpdateEntiy(EmployeePayHistoryDto t) { var dbentity = typeAdapter.ConvertDtoToEntities(t); dbentity.State = State.Modified; context.ChangeObjectState <EmployeePayHistory>(dbentity, StateHelpers.GetEquivalentEntityState(dbentity.State)); uow.Save(); return(true); }
/// <summary> /// Get the List ofEmployeePayHistorydto. /// </summary> /// <param name="_EmployeePayHistoryDto">The EmployeePayHistory dto.</param> /// <example><code> HTTP GET: api/EmployeePayHistory/?pageindex=1&pagesize=10&....</code></example> /// <returns>DatagridData List of EmployeePayHistoryDto</returns> public EasyuiDatagridData <EmployeePayHistoryDto> Get([FromUri] EmployeePayHistoryDto _EmployeePayHistoryDtos, int pageIndex = 1, int pageSize = 10) { var pagedlist = new PagedList <EmployeePayHistoryDto> { _EmployeePayHistoryDtos }; pagedlist.PageIndex = pageIndex; pagedlist.PageSize = pageSize; return(_EmployeePayHistoryBO.FindAll(pagedlist)); }
/// <summary> /// Converts the dto to entities. /// </summary> /// <param name="_ EmployeePayHistoryDto">The EmployeePayHistory dto.</param> /// <param name="ef EmployeePayHistory">已存的EntityFramework实体 ef EmployeePayHistory</param> /// <param name="skipNullPropertyValue">if set to <c>true</c> [skip null property value].</param> /// <returns>EmployeePayHistory</returns> public EmployeePayHistory ConvertDtoToEntities(EmployeePayHistoryDto _EmployeePayHistoryDto, EmployeePayHistory efEmployeePayHistory, bool skipNullPropertyValue) { if (_EmployeePayHistoryDto == null && efEmployeePayHistory == null) { throw new ArgumentNullException("models should not be null"); } ConvertObjectWithCheckNull(_EmployeePayHistoryDto, skipNullPropertyValue, efEmployeePayHistory); return(efEmployeePayHistory); }
public void TestGetEntiyByPK(Int32 pkid) { var _EmployeePayHistoryBO = new EmployeePayHistoryBO(new FakeEmployeePayHistoryConverter()); var dtoEntity = new EmployeePayHistoryDto() { EmployeeID = pkid }; var dbResult = _EmployeePayHistoryBO.GetEntiyByPK(dtoEntity); Assert.NotNull(dbResult); }
public void TestFindEnties(EmployeePayHistoryDto _EmployeePayHistoryDto) { var _EmployeePayHistoryBO = new EmployeePayHistoryBO(new EmployeePayHistoryConverter()); bool hasAdded = _EmployeePayHistoryBO.CreateEntiy(_EmployeePayHistoryDto); var dbResult = _EmployeePayHistoryBO.FindEnties(new PagedList <EmployeePayHistoryDto> { _EmployeePayHistoryDto }); Assert.NotNull(dbResult); Assert.True(dbResult.Total > 0); }
// GET: EmployeePayHistory/Find/?pageindex=1&pagesize=10&.... public async Task <JsonResult> Find(EmployeePayHistoryDto _EmployeePayHistoryDto, 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 <EmployeePayHistoryDto>, EmployeePayHistoryDto>(_EmployeePayHistoryDto, pageQueryString))); }
public void TransformDTOtoEmployeePayHistory() { var adapter = new TypeAdapter(); var eph = new EmployeePayHistoryDto() { EmployeeID = 1, ModifiedDate = DateTime.Now }; var dto = adapter.Transform <EmployeePayHistoryDto, EmployeePayHistory>(eph); Assert.Equal(dto.EmployeeID, eph.EmployeeID); }
/// <summary> /// Updates the with attach entiy asynchronous. /// </summary> /// <param name="tDTo">The t d to.</param> /// <returns></returns> public async Task <int> UpdateWithAttachEntiyAsync(EmployeePayHistoryDto tDTo) { var dbentity = typeAdapter.ConvertDtoToEntities(tDTo); if (StateHelpers.GetEquivalentEntityState(dbentity.State) == StateHelpers.GetEquivalentEntityState(State.Detached)) { entiesrepository.Attach(dbentity); } dbentity.State = State.Modified; context.ChangeObjectState <EmployeePayHistory>(dbentity, StateHelpers.GetEquivalentEntityState(dbentity.State)); return(await uow.SaveAsync()); }
/// <summary> /// Update With Attach the EmployeePayHistoryEntiy. /// </summary> /// <param name="Entiy">The Entiy.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</return public bool UpdateWithAttachEntiy(EmployeePayHistoryDto t) { var dbentity = typeAdapter.ConvertDtoToEntities(t); if (StateHelpers.GetEquivalentEntityState(dbentity.State) == StateHelpers.GetEquivalentEntityState(State.Detached)) { entiesrepository.Attach(dbentity); } dbentity.State = State.Modified; context.ChangeObjectState <EmployeePayHistory>(dbentity, StateHelpers.GetEquivalentEntityState(dbentity.State)); uow.Save(); return(true); }
/// <summary> /// Converts the entities to dto. /// </summary> /// <param name="_EmployeePayHistory">The EmployeePayHistory entity</param> /// <returns>EmployeePayHistoryDto</returns> public EmployeePayHistoryDto ConvertEntitiesToDto(EmployeePayHistory _EmployeePayHistory) { if (_EmployeePayHistory == null) { throw new ArgumentNullException("models should not be null"); } var _EmployeePayHistoryDto = new EmployeePayHistoryDto(); _EmployeePayHistoryDto.EmployeeID = _EmployeePayHistory.EmployeeID; _EmployeePayHistoryDto.RateChangeDate = _EmployeePayHistory.RateChangeDate; _EmployeePayHistoryDto.Rate = _EmployeePayHistory.Rate; _EmployeePayHistoryDto.PayFrequency = _EmployeePayHistory.PayFrequency; _EmployeePayHistoryDto.ModifiedDate = _EmployeePayHistory.ModifiedDate; return(_EmployeePayHistoryDto); }
/// <summary> /// Builds all query. /// </summary> /// <param name="_EmployeePayHistory">The EmployeePayHistory dto.</param> /// <returns></returns> private static Expression <Func <EmployeePayHistory, bool> > BuildAllQuery(EmployeePayHistoryDto _employeepayhistoryDto) { var list = new List <Expression <Func <EmployeePayHistory, bool> > >(); if (_employeepayhistoryDto.EmployeeID > 0) { list.Add(c => c.EmployeeID == _employeepayhistoryDto.EmployeeID); } //Add more condition Expression <Func <EmployeePayHistory, bool> > entityQueryConditionTotal = null; foreach (var e in list) { entityQueryConditionTotal = entityQueryConditionTotal == null ? e : entityQueryConditionTotal.And(e); } return(entityQueryConditionTotal); }
public bool Post(EmployeePayHistoryDto value) { return(_EmployeePayHistoryBO.CreateEntiy(value)); }