예제 #1
0
        public async Task <ApiRequestResult> AddAsync(MemberDto dto)
        {
            var command = dto.EntityMap <MemberDto, Member>();
            await _memberRepository.AddAsync(command);

            return(ApiRequestResult.Success("添加成功"));
        }
예제 #2
0
        /// <summary>
        /// 会员注册
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <IResultModel> Register(RegisterModel model)
        {
            //用户名称是否存在
            var existsUserName = _repository.ExistsUserName(model.UserName);

            if (existsUserName)
            {
                return(ResultModel.HasExists);
            }
            //邮箱是否存在
            var existsEmail = _repository.ExistsEmail(model.UserName);

            if (existsUserName)
            {
                return(ResultModel.HasExists);
            }
            var password = _passwordHandler.Encrypt(model.UserName, model.Password);
            var entity   = new MemberEntity
            {
                UserName = model.UserName,
                Email    = model.Email,
                NickName = model.NickName,
                Password = model.Password,
                Sex      = model.Sex
            };
            var result = await _repository.AddAsync(entity);

            return(ResultModel.Result(result));
        }
예제 #3
0
        public async Task <Unit> Handle(CreateMemberCommand request, CancellationToken cancellationToken)
        {
            var member = Member.Create(request.MemberId, request.Login, request.Email, request.FirstName, request.LastName, request.Name);

            await _memberRepository.AddAsync(member);

            return(Unit.Value);
        }
예제 #4
0
        public async Task <Member> CreateAsync(Member newData)
        {
            if (newData == null)
            {
                throw new ArgumentNullException(nameof(newData));
            }

            await _memberRepository.AddAsync(newData);

            return(newData);
        }
예제 #5
0
 public async Task AddAsync(MemberDetailsDto dto)
 {
     dto.Id = Guid.NewGuid();
     var member = new Member
     {
         Id          = dto.Id,
         Name        = dto.Name,
         Description = dto.Description
     };
     await _memberRepository.AddAsync(member);
 }
예제 #6
0
        public async Task <IResultModel> Add(MemberAddModel model)
        {
            var entity = _mapper.Map <MemberEntity>(model);
            //if (await _repository.Exists(entity))
            //{
            //return ResultModel.HasExists;
            //}
            var result = await _repository.AddAsync(entity);


            return(ResultModel.Result(result));
        }
예제 #7
0
        public async Task <MemberResponse> SaveAsync(MemberSaveResource memberSaveResource)
        {
            try
            {
                var item = _mapper.Map <MemberSaveResource, Member>(memberSaveResource);
                await _memberRepository.AddAsync(item);

                var responseResource = _mapper.Map <Member, MemberResource>(item);
                return(new MemberResponse(responseResource));
            }
            catch (Exception ex)
            {
                return(new MemberResponse(400, "Unexpected error", "Error", ex.Message));
            }
        }
        public async Task <IActionResult> Create(MemberCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                var member = new Member
                {
                    FirstName      = model.FirstName,
                    LastName       = model.LastName,
                    Phone          = model.Phone,
                    Email          = model.Email,
                    DateRegistered = DateTime.Now
                };

                await repository.AddAsync(member);

                await unitOfWork.CompleteAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
예제 #9
0
 public async Task <Pilot> AddPilot(Pilot pilot)
 {
     return(await _memberRepository.AddAsync(pilot));
 }