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 Update(string botDeatils, int id) { HardwareCollectorCommand ConvertedBotDeatils = JsonConvert.DeserializeAnonymousType(botDeatils, new HardwareCollectorCommand()); var cpu = new BotInfoCommand { BotId = id, HardwareName = ConvertedBotDeatils.Cpu.HardwareName, HardwareType = ConvertedBotDeatils.Cpu.HardwareType, Performance = ConvertedBotDeatils.Cpu.Performance, OtherInformation = ConvertedBotDeatils.Cpu.OtherInformation }; await _mediator.Send(cpu); var gpu = new BotInfoCommand { BotId = id, HardwareName = ConvertedBotDeatils.Gpu.HardwareName, HardwareType = ConvertedBotDeatils.Gpu.HardwareType, Performance = ConvertedBotDeatils.Gpu.Performance, OtherInformation = ConvertedBotDeatils.Gpu.OtherInformation }; await _mediator.Send(gpu); var os = new BotInfoCommand { BotId = id, HardwareName = ConvertedBotDeatils.Os.HardwareName, HardwareType = ConvertedBotDeatils.Os.HardwareType, Performance = ConvertedBotDeatils.Os.Performance, OtherInformation = ConvertedBotDeatils.Os.OtherInformation }; await _mediator.Send(os); var ram = new BotInfoCommand { BotId = id, HardwareName = ConvertedBotDeatils.Ram.HardwareName, HardwareType = ConvertedBotDeatils.Ram.HardwareType, Performance = ConvertedBotDeatils.Ram.Performance, OtherInformation = ConvertedBotDeatils.Ram.OtherInformation }; await _mediator.Send(ram); for (var i = 0; i < ConvertedBotDeatils.OtherHarwares[0].Count; i++) { var command = new BotInfoCommand { BotId = id, HardwareName = ConvertedBotDeatils.OtherHarwares[0][i].HardwareName, HardwareType = ConvertedBotDeatils.OtherHarwares[0][i].HardwareType, Performance = ConvertedBotDeatils.OtherHarwares[0][i].Performance, OtherInformation = ConvertedBotDeatils.OtherHarwares[0][i].OtherInformation }; await _mediator.Send(command); } }