private void UpdateDepartmentOrCompanyOpinion(WeiDaKa persistedModel, WeiDaKaDTO itemDto, UserDTO operatorDTO = null)
        {
            var oldDTO = persistedModel.ToDto();

            // 可以修改的字段
            var current = oldDTO.ToModel();

            current.DepartmentOrCompanyOpinion           = itemDto.DepartmentOrCompanyOpinion;
            current.DepartmentOrCompanyOpinionApproverId = itemDto.DepartmentOrCompanyOpinionApproverId;

            if (persistedModel.Status == KaoQinStatusDTO.Submited.ToString())
            {
                current.Status   = KaoQinStatusDTO.Approved.ToString();
                current.Approved = DateTime.UtcNow;
            }

            this.OperationLog(KaoQinMessagesResources.Update_WeiDaKa, current.ToDto(), oldDTO, operatorDTO);

            //Merge changes
            _Repository.Merge(persistedModel, current);
            //commit unit of work
            _Repository.UnitOfWork.Commit();
        }
        private void ValidateModel(WeiDaKa 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.Type.IsNullOrBlank())
            {
                throw new DefinedException(KaoQinMessagesResources.WeiDaKa_Type_Empty);
            }

            if (model.Reason.IsNullOrBlank())
            {
                throw new DefinedException(KaoQinMessagesResources.WeiDaKa_Reason_Empty);
            }

            if (_Repository.Exists(model))
            {
                throw new DataExistsException(string.Format(KaoQinMessagesResources.WeiDaKa_Exists_WithValue, model.UserId, model.ActionTime.ToLocalTime().ToString("yyyy-MM-dd ddd"), model.Type));
            }
        }
 public static WeiDaKaDTO ToDto(this WeiDaKa model)
 {
     return(Mapper.Map <WeiDaKaDTO>(model));
 }