public async Task <IActionResult> RegisterAccount([FromBody] AccountRegister account) { var client = _httpClientFactory.CreateClient("appIDUser"); client.DefaultRequestHeaders.Add("Authorization", "Bearer " + getIAM()); var myContent = JsonConvert.SerializeObject(account); var buffer = System.Text.Encoding.UTF8.GetBytes(myContent); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var content = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("grant_type", "urn:ibm:params:oauth:grant-type:apikey"), new KeyValuePair <string, string>("apikey", "aIr9I1oFfXQTYk_6p4ddNVe8LB4wbO70YPCmADnfkAmx") }); var result = client.PostAsync("management/v4/" + tenantId + "/cloud_directory/sign_up", byteContent).Result; string resultContent = result.Content.ReadAsStringAsync().Result; if (resultContent.Contains(account.emails[0].value)) { Partner partnerRegister = new Partner(); partnerRegister.Email = account.emails[0].value; partnerRegister.Id = Guid.NewGuid() + ""; partnerRegister.IsDelete = false; partnerRegister.NameCompany = account.userName; _repository.Create(partnerRegister); return(Ok("Dang ky thanh cong " + account.emails[0].value)); } return(Ok(resultContent)); }
public IActionResult Create([FromBody] Partner Partner) { var claims = User.Claims.Select(claim => new { claim.Type, claim.Value }).ToDictionary(t => t.Type, t => t.Value); if (claims.ContainsKey("name")) { if (claims["name"].Equals("ADMIN") || claims["name"].Equals("MANAGER")) { Partner.Id = Guid.NewGuid() + ""; Partner.IsDelete = false; return(Ok(_repository.Create(Partner))); } } else { return(Forbid()); } return(Forbid()); }
public IActionResult Create([FromBody] Partner Partner) { Partner.Id = Guid.NewGuid() + ""; Partner.IsDelete = false; return(Ok(_repository.Create(Partner))); }
public void CreatePartner() { PartnerRepository.Create(this); }