Exemplo n.º 1
0
        public async Task <object> PostOauthLogin([FromBody] OauthLoginViewModel model)
        {
            MessageBase2 result = new MessageBase2();

            result.Data = new MemberLoginResultModel();
            int userId;

            userId = await _memberService.ExistAsync(model.Type, model.UserName);

            if (userId <= 0)  //如果用户已经存在,则直接返回,如果不存在则注册
            {
                //头像保存到本地
                string       fileName = SysHelper.RandomFileName() + ".png";
                QCloudHelper qCloud   = new QCloudHelper();


                Stream stream = HttpHelper.GetHttpWebRequest2(model.Figureurl);
                var    b      = qCloud.UploadFile("/upload/portrait/", fileName, stream);

                CosFileStatDto cosDto = new CosFileStatDto()
                {
                    AccessUrl    = b.AccessUrl,
                    Url          = b.Url,
                    SourceUrl    = b.SourceUrl,
                    ResourcePath = b.ResourcePath
                };
                await _cosFileStatService.AddAsync(cosDto);


                userId = await _memberService.AddAsync(model.Type, model.UserName, HttpContext.GetUserIp(), "", model.Nickname, model.Gender, OtherConfig.PortraitWebDir + fileName);
            }
            MemberDto dto = await _memberService.FindAsync(userId);

            result.Data = ConvertHelper.ChangeType <MemberLoginResultModel>(dto);


            return(result);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Add(AddMemberModel model)
        {
            if (ModelState.IsValid)
            {
                var cliemUserID = User.Claims.FirstOrDefault(a => a.Type.Equals("UserID"));
                var userID      = int.Parse(cliemUserID.Value.ToString());
                var addedMember = new Member()
                {
                    CreatedDate          = DateTime.Now,
                    isTRCitezen          = model.isTRCitizen == "on",
                    isTRIDCitizenVerfied = true,
                    LastUpdatedDate      = DateTime.Now,
                    TRIDNo                = model.TRIDNo,
                    Name                  = model.Name.ToUpper(),
                    Surname               = model.Surname.ToUpper(),
                    UserID                = userID,
                    BirthDate             = new DateTime(model.BirthYear, 1, 1),
                    TotalRentConut        = model.MaxRentLimit,
                    EMail                 = model.EMail.ToLower(),
                    PhoneNumber           = model.PhoneNumber,
                    isEMailVerified       = true,
                    isPhoneNumberVerified = model.isPhonumberVerified == "on",
                    Address               = model.Address.ToUpper(),
                    isAddressVerified     = model.isAddressVerified == "on",
                    Status                = model.isActive == "on"?MemberStatusType.Acitive:MemberStatusType.Suspanded,
                    RemainedRentConut     = model.MaxRentLimit,
                    AwaableToRent         = model.isAwaableToRent == "on"
                };

                var operationResult = await memberService.AddAsync(addedMember);

                if (operationResult.isSuccess)
                {
                    return(RedirectToAction("Index"));
                }
                foreach (var item in operationResult.Errors)
                {
                    ModelState.AddModelError("", item);
                }
            }
            return(View(model));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Post()
        {
            var member = await _memberService.AddAsync(UserFirebaseId, UserEmail, UserDisplayName);

            return(Ok(member));
        }
        public async Task <ActionResult> AddAsync(MemberDetailsDto dto)
        {
            await _memberService.AddAsync(dto);

            return(CreatedAtAction(nameof(Get), new { id = dto.Id }, null));
        }