Beispiel #1
0
        public ReturnInfo AddProfile(ProfileInputDto lvInputDto)
        {
            ReturnInfo    RInfo     = new ReturnInfo();
            StringBuilder sb        = new StringBuilder();
            string        ProfileNo = lvInputDto.ProfileNo;

            string ValidateInfo = Helper.ValidateProfileInputDto(lvInputDto);

            sb.Append(ValidateInfo);
            if (string.IsNullOrEmpty(ValidateInfo))
            {
                try
                {
                    _unitOfWork.RegisterNew(lvInputDto);
                    bool result = _unitOfWork.Commit();
                    RInfo.IsSuccess = result;
                    RInfo.ErrorInfo = sb.ToString();
                    return(RInfo);
                }
                catch (Exception ex)
                {
                    _unitOfWork.Rollback();
                    sb.Append(ex.Message);
                    RInfo.IsSuccess = false;
                    RInfo.ErrorInfo = sb.ToString();
                    return(RInfo);
                }
            }
            else
            {
                RInfo.IsSuccess = false;
                RInfo.ErrorInfo = sb.ToString();
                return(RInfo);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 请假单验证
        /// </summary>
        /// <param name="entity">请假单对象</param>
        public static string ValidateProfileInputDto(ProfileInputDto entity)
        {
            //基础验证
            StringBuilder sb = BasicValidate <ProfileInputDto>(entity);

            return(sb.ToString());
        }
Beispiel #3
0
        public ProfileResponseDto UpdateProfile(int pid, ProfileInputDto profileInputDto)
        {
            profileInputDto.Validate();

            var profile = _profileMapper.map(profileInputDto);

            return(_profileMapper.map(_profilesRepository.Update(pid, profile)));
        }
Beispiel #4
0
        public ProfileResponseDto CreateProfile(string uid, ProfileInputDto profileInputDto)
        {
            profileInputDto.Validate();
            var profile = _profileMapper.map(profileInputDto);

            profile.UID = uid;
            return(_profileMapper.map(_profilesRepository.Create(profile)));
        }
Beispiel #5
0
 public Profile map(ProfileInputDto profile)
 {
     return(new Profile()
     {
         Name = profile.Name,
         Address = profile.Location != null ? profile.Location.Address : null,
         Point = profile.Location != null?_geometryMapper.map(profile.Location) : null,
                     ProfileSkills = profile.Skills != null?profile.Skills.Select(g => _skillMapper.mapToSkillProfile(g)).ToList() : null
     });
 }
Beispiel #6
0
        public static void Validate(this ProfileInputDto profileInputDto)
        {
            if (string.IsNullOrWhiteSpace(profileInputDto.Name))
            {
                throw new InvalidInputException("Empty 'Profile.Name' not allowed");
            }

            if (profileInputDto.Location == null)
            {
                throw new InvalidInputException("Profile without location is not allowed");
            }
            profileInputDto.Location.Validate();
        }
Beispiel #7
0
        public ReturnInfo UpdateLeave(ProfileInputDto entity)
        {
            ReturnInfo    RInfo        = new ReturnInfo();
            StringBuilder sb           = new StringBuilder();
            string        ValidateInfo = Helper.ValidateProfileInputDto(entity);

            sb.Append(ValidateInfo);
            if (string.IsNullOrEmpty(ValidateInfo))
            {
                Domain.Profile lv = _profileRepository.GetByID(entity.ProfileNo).FirstOrDefault();
                if (lv != null)
                {
                    try
                    {
                        lv.EmpName       = entity.EmpName;
                        lv.EmpIDNo       = entity.EmpIDNo;
                        lv.EmpTelNo      = entity.EmpTelNo;
                        lv.RelationVal   = entity.RelationVal;
                        lv.IsDimissioned = entity.IsDimissioned;
                        lv.UpdateTime    = DateTime.Now;
                        lv.Updator       = entity.Updator;
                        _unitOfWork.RegisterDirty(lv);
                        bool result = _unitOfWork.Commit();
                        RInfo.IsSuccess = result;
                        RInfo.ErrorInfo = sb.ToString();
                        return(RInfo);
                    }
                    catch (Exception ex)
                    {
                        _unitOfWork.RegisterClean(lv);
                        _unitOfWork.Rollback();
                        sb.Append(ex.Message);
                        RInfo.IsSuccess = false;
                        RInfo.ErrorInfo = sb.ToString();
                        return(RInfo);
                    }
                }
                else
                {
                    RInfo.IsSuccess = false;
                    RInfo.ErrorInfo = "未找到该档案!";
                    return(RInfo);
                }
            }
            else
            {
                RInfo.IsSuccess = false;
                RInfo.ErrorInfo = sb.ToString();
                return(RInfo);
            }
        }
        public ActionResult <ProfileResponseDto> CreateProfile([FromBody] ProfileInputDto profile)
        {
            var uid = this.User.GetSub();

            return(_profileService.CreateProfile(uid, profile));
        }
        public async Task <ProfileResponseDto> UpdateProfile([FromRoute(Name = "pid")] int pid, [FromBody] ProfileInputDto profile)
        {
            var p = _profileService.GetProfile(pid);

            var t = await _authService.AuthorizeAsync(this.User, p.Uid, new OwnerOrAdminRequirement());

            if (!t.Succeeded)
            {
                throw new UnauthorizedResourceAccessException("Not authorized to update this Profile");
            }

            return(_profileService.UpdateProfile(pid, profile));
        }