//[ValidateAntiForgeryToken] public async Task <IActionResult> SignonAggregatorGroup([FromBody] AggregatorGroupRegistModel model) { if (ModelState.IsValid) { if (_accountContext.AggregatorGroups.Any(x => x.AggName == model.AggregatorGroupName)) { IdentityError error = (_userManager.ErrorDescriber as LocalizedIdentityErrorDescriber).TargetAggGroupHasAlready(model.AggregatorGroupName); IdentityResult _result = IdentityResult.Failed(error); return(BadRequest(new { Result = _result })); } AggregatorGroupEF aggregatorGroup = new AggregatorGroupEF(); aggregatorGroup.ID = Guid.NewGuid().ToString(); aggregatorGroup.AggName = model.AggregatorGroupName; aggregatorGroup.Representation = model.Represenation; aggregatorGroup.Address = model.Address; aggregatorGroup.CreateDT = DateTime.Now; aggregatorGroup.PhoneNumber = model.PhoneNumber; await _accountContext.AddAsync(aggregatorGroup); await _accountContext.SaveChangesAsync(); return(Ok(aggregatorGroup.ID)); } return(BadRequest()); }
public async Task <IActionResult> SubmitUserStatus([FromBody] SubmitUserStatusModel model) { if (ModelState.IsValid) { string name = _claimsManager.GetClaimsValue(HttpContext.User, ClaimTypes.Name); var user_account = await accountContext.ContractorUsers.FindAsync(model.UserId); var user = await accountContext.VwContractorusers.FindAsync(model.UserId); if (user_account == null) { IdentityError error = (_userManager.ErrorDescriber as LocalizedIdentityErrorDescriber).UserNotFound(); IdentityResult _result = IdentityResult.Failed(error); return(BadRequest(new { Result = _result })); } user_account.ContractStatus = model.Status; if (model.Status == PEIU.Models.ContractStatusCodes.Activating) { var pk = await accountContext.Users.FindAsync(model.UserId); pk.SignInConfirm = true; string sender = $"{user.AggName} 운영팀"; await _emailSender.SendEmailAsync(sender, $"가입을 축하합니다. 승인날짜:{DateTime.Now}", $"{pk.FirstName + pk.LastName} 고객님이 회원가입이 정상적으로 처리되었습니다", pk.Email); } await accountContext.SaveChangesAsync(); if (model.Notification) { IEnumerable <string> email_address = null; if (HttpContext.User.IsInRole(UserRoleTypes.Supervisor)) { var targets = await _userManager.GetUsersInRoleAsync(UserRoleTypes.Supervisor); email_address = targets.Select(x => x.Email); } else { string group_id = _claimsManager.GetClaimsValue(HttpContext.User, UserClaimTypes.AggregatorGroupIdentifier); var role_user = accountContext.VwAggregatorusers.Where(x => x.AggGroupId == group_id); email_address = role_user.Select(x => x.Email); } string senderName = $"{name} (운영팀)"; try { await _emailSender.SendEmailAsync(senderName, $"{name} 고객님의 새로운 결제가 확인되었습니다", $"대상 고객: {name}\n결제 내용: {model.Status}\n결제 사유: {model.Reason}", email_address.ToArray()); } catch (Exception ex) { } } } return(Ok()); }
public async Task ConnectSiteToCustomer(string userid, int siteid) { var site = await _accountContext.ContractorSites.FindAsync(siteid); if (site == null) { BadRequest("없는 사이트"); } site.ContractUserId = userid; await _accountContext.SaveChangesAsync(); }