private void ValidateModel(WaiQin model) { if (model.Name.IsNullOrBlank()) { throw new DefinedException(KaoQinMessagesResources.UserName_Empty); } if (model.UserId.IsNullOrBlank()) { throw new DefinedException(KaoQinMessagesResources.UserId_Empty); } if (model.DepartmentId == 0) { throw new DefinedException(KaoQinMessagesResources.DepartmentId_Empty); } if (model.Position.IsNullOrBlank()) { throw new DefinedException(KaoQinMessagesResources.Position_Empty); } if (model.OutPlace.IsNullOrBlank()) { throw new DefinedException(KaoQinMessagesResources.WaiQin_OutPlace_Empty); } if (model.OutReason.IsNullOrBlank()) { throw new DefinedException(KaoQinMessagesResources.WaiQin_OutReason_Empty); } if (model.OutTime > model.InTime) { throw new DefinedException(KaoQinMessagesResources.WaiQin_OutTime_Greater_Than_InTime); } if (_Repository.Exists(model)) { throw new DataExistsException(string.Format(KaoQinMessagesResources.WaiQin_Exists_WithValue, model.UserId, model.OutTime.ToLocalTime())); } }
private void UpdateCompanyLeaderOpinion(WaiQin persistedModel, WaiQinDTO itemDto, UserDTO operatorDTO = null) { var oldDTO = persistedModel.ToDto(); // 可以修改的字段 var current = oldDTO.ToModel(); current.CompanyLeaderOpinion = itemDto.CompanyLeaderOpinion; current.CompanyLeaderOpinionApproverId = itemDto.CompanyLeaderOpinionApproverId; if (persistedModel.Status == KaoQinStatusDTO.Submited.ToString()) { current.Status = KaoQinStatusDTO.Approved.ToString(); current.Approved = DateTime.UtcNow; } this.OperationLog(KaoQinMessagesResources.Update_WaiQin, current.ToDto(), oldDTO, operatorDTO); //Merge changes _Repository.Merge(persistedModel, current); //commit unit of work _Repository.UnitOfWork.Commit(); }
public static WaiQinDTO ToDto(this WaiQin model) { return(Mapper.Map <WaiQinDTO>(model)); }