public override department ToDto(Department value)
        {
            department d = new department();

            d.description = value.Description;
            d.id          = value.Id;
            d.code        = value.Code;
            d.name        = value.Name;
            if (value.JobPositions != null)
            {
                d.jobPositions = new List <jobPosition>();
                JobPositionConverter jpConverter = new JobPositionConverter(DbContext);
                var jps = value.JobPositions.OrderBy(j => j.Code);
                foreach (var jp in jps)
                {
                    d.jobPositions.Add(jpConverter.ToDto(jp));
                }
            }
            d.parentDepartmentId = value.ParentDepartment?.Id;
            if (value.Leader != null)
            {
                // EmployeeConverter emConverter = new EmployeeConverter();
                // d.leader = emConverter.Convert(value.Leader);
            }
            return(d);
        }
Beispiel #2
0
        public override employee ToDto(Employee model)
        {
            employee em = new employee()
            {
                address       = model.Address,
                birthday      = model.BirthDay,
                code          = model.Code,
                birthdayType  = model.BirthDayType,
                description   = model.Description,
                education     = model.Education,
                email         = model.Email,
                id            = model.Id,
                idCardCode    = model.IdCardCode,
                isVirtual     = model.IsVirtual,
                mobileNumber  = model.MobileNumber,
                name          = model.Name,
                passWord      = model.Passwrod,
                serveState    = model.ServeState,
                sex           = model.Sex,
                nationality   = model.Nationality,
                userId        = model.UserId,
                pictureUrl    = model.PictureUrl,
                QQ            = model.QQ,
                WeChat        = model.WeChat,
                userRoleIds   = model.UserRoleIds == null?null:model.UserRoleIds.Split(','),
                permissionIds = model.PermissionIds == null ? null : model.PermissionIds.Split(','),
            };

            if (model.Department != null)
            {
                em.departmentId   = model.Department.Id;
                em.departmentName = model.Department.Name;
            }
            if (model.ServingRecords != null)
            {
                var jpC = new JobPositionConverter(DbContext);
                List <servingRecord> list = new List <servingRecord>();
                foreach (var item in model.ServingRecords)
                {
                    servingRecord record = new servingRecord
                    {
                        beginTime    = item.BeginTime,
                        employeeId   = item.Employee.Id,
                        endTime      = item.EndTime,
                        id           = item.Id,
                        isConcurrent = item.IsConcurrent,
                        isCurrent    = item.IsCurrent,
                        jobPosition  = jpC.ToDto(item.JobPosition)
                    };
                    list.Add(record);
                }
                em.servingRecords = list.ToArray();
            }
            if (model.Image != null)
            {
                em.image = Convert.ToBase64String(model.Image);
            }
            return(em);
        }