public async Task <ResultModel> SendInformation(CreateAboutMeModel model) { HttpResponseMessage req = await client.PostAsync("api/users/add", new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json")); if (req != null && req.IsSuccessStatusCode) { var data = await req.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <ResultModel>(data)); } else { return new ResultModel() { IsSuccess = false, Message = "fail." } }; }
public IHttpActionResult AddUser([FromBody] CreateAboutMeModel model) { var user = new User() { Email = model.Email }; var userResponse = UserRepo.Add(user); if (userResponse == true) { var aboutme = new AboutMe() { UserId = UserRepo.Where(c => c.Email == model.Email).SingleOrDefault().Id, NameSurname = model.NameSurname, Image = model.ImageUrl, Age = Convert.ToInt32(model.Age), Gender = model.Gender, Description = model.Description, Background = model.Background, Foreground = model.Foreground }; var compare = WebSiteRepo.List(); for (int i = 0; i < model.AnalysisText.Length; i++) { foreach (var item in compare) { if (item.Style1.ToLower() == model.AnalysisText[i].ToLower()) { var projectModel = new Project() { UserId = aboutme.UserId, Url = "empty-url", WebSourceCode = compare[i].SourceCode }; ProjectRepo.Add(projectModel); break; } } } var response = AboutmeRepo.Add(aboutme); if (response == true) { return(Success("Successful create website")); } else { return(Error("UnSuccessful create website")); } } else { return(Error("Unsuccessful create account")); } }