public async Task <int> LogDebugAsync(CreateLogModel model) { if (model is null || (string.IsNullOrEmpty(model.Title) && string.IsNullOrEmpty(model.Message) && model.Exception is null)) { return(default);
//Create Health Log public async Task <bool> CreateHealthLog(string date) { _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Token", "dc7fdbb7c51275af932b2669ccb737fe91432018"); var createLogModel = new CreateLogModel() { Date = date }; var json = JsonConvert.SerializeObject(createLogModel); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = await _client.PostAsync("http://healthlog-deployment.dbmvyepwfm.us-east-1.elasticbeanstalk.com/api/logs/", content); var result = await response.Content.ReadAsStringAsync(); JObject jObject = JsonConvert.DeserializeObject <dynamic>(result); var token = jObject.Value <string>("token"); Settings.AccessToken = token; Console.WriteLine(Settings.AccessToken); return(response.IsSuccessStatusCode); }
public async Task <string> CreateLogTest(CreateLogModel model) { if (!ModelState.IsValid) { return("failed"); } if (model.Title == "") { return("please enter a title!"); } var user = await _userManager.GetUserAsync(User); if (user == null || user.Id != model.UserId) { return("failed,Invalid attempt,you are not a Valid User"); } //make sure,there is no same name Log for this User var queryOfLog = _context.Logs.Where(q => q.BelongerId == model.UserId && q.Title == model.Title); if (!queryOfLog.Any()) { //Create the Log; var log = new UserLog() { BelongerId = model.UserId, Title = model.Title }; _context.Logs.Add(log); _context.SaveChanges(); return("finished"); } return("there is a same named log in your list,please create this log by another log name"); }