public async Task <JsonResult> BotlogAsync([FromBody] LogModel model) { if (!ModelState.IsValid) { return(Json(new { success = false, result = "Invalid Model" })); } var Keyquery = new GetBotByKeyUniqueQuery { KeyUnique = model.KeyUnique }; var botresult = _mediator.Send(Keyquery); if (botresult == null) { return(Json(new { success = false, result = "Bot is not exist" })); } var query = new BotLogCommand { BotId = botresult.Result.Id, Message = model.Message, Type = model.Type }; var result = await _mediator.Send(query); if (result.Suceeded) { return(Json(new { success = true, result = "Work" })); } return(Json(new { success = false, result = "Save not success" })); }
public async Task <JsonResult> BotDeatilsAsync([FromBody] BotDeatilsModel model) { if (!ModelState.IsValid) { return(Json(new { success = false, result = "Invalid Model" })); } var Keyquery = new GetBotByKeyUniqueQuery { KeyUnique = model.KeyUnique }; var botresult = _mediator.Send(Keyquery); if (botresult == null) { return(Json(new { success = false, result = "Bot is not exist" })); } var Botquery = new BotInfoCommand { BotId = botresult.Result.Id, HardwareName = model.HardwareName, HardwareType = model.HardwareType, OtherInformation = model.OtherInformation, Performance = model.Performance }; var result = await _mediator.Send(Botquery); if (result.Suceeded) { return(Json(new { success = true, result = "Work" })); } return(Json(new { success = false, result = "Save not success" })); }
public async Task <JsonResult> RegbotAsync([FromBody] BotRegisterModel model) { if (!ModelState.IsValid) { return(Json(new { success = false, result = "Invalid Model" })); } #if (!DEBUG) // Release appsettingsModel JsonString = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/appsettings.json"), new appsettingsModel()); #else // Debug appsettingsModel JsonString = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel()); #endif if (JsonString.Stump.KeyCertified != model.KeyCertified) { return(Json(new { success = false, result = "Key does not match" })); } var Keyquery = new GetBotByKeyUniqueQuery { KeyUnique = model.KeyUnique }; var botresult = _mediator.Send(Keyquery); if (botresult.Result == null) { var command = new RegbotCommand { UserName = model.UserName, Domain = model.Domain, City = model.City, CountryCode = model.CountryCode, KeyUnique = model.KeyUnique, LastIPAddress = model.LastIPAddress, CreationDateUTC = DateTime.Now, LastLoggedInUTC = DateTime.Now }; var result = await _mediator.Send(command); if (result.Suceeded) { return(Json(new { success = true, result = "Work" })); } } else { var BotUpdateCommand = new UpdateBotStatusCommand { id = botresult.Result.Id }; var result = await _mediator.Send(BotUpdateCommand); return(Json(new { success = true, result = "Updated" })); } return(Json(new { success = false, result = "Registration not success" })); }