public async Task <IActionResult> UpdateMaster(RepairWithMasterModel model) { try { ViewBag.Role = await InitRole(); var repairMksResult = JsonConvert.DeserializeObject <MksResponseResult>( await RequestExecutor.ExecuteRequest(Scope.RepairsMksUrl, new RestRequest("/UpdateRepairMaster", Method.POST) .AddHeader("Content-type", "application/json") .AddJsonBody(JsonConvert.SerializeObject(model)))); if (!repairMksResult.Success) { throw new Exception(repairMksResult.Data); } return(Json( new { Success = true, Data = "ok" })); } catch (Exception exception) { return(Json(new { Success = false, exception.Message })); } }
public async Task <IActionResult> UpdateRepairMaster([FromBody] RepairWithMasterModel model) { try { await _repairsRepository.UpdateRepairMaster(model); return(Json( new { Success = true, Data = "ok" })); } catch (Exception exception) { return(Json(new { Success = false, exception.Message })); } }
public async Task UpdateRepairMaster(RepairWithMasterModel model) { var repair = await _context.Repairs.FirstOrDefaultAsync(x => x.RepairId == long.Parse(model.RepairId)); if (repair == null) { throw new Exception("Repair not found"); } var personMksResultWithClient = JsonConvert.DeserializeObject <MksResponseResult>( await RequestExecutor.ExecuteRequest(Scope.PersonMksUrl, new RestRequest("/GetPersonIdByFIO", Method.POST) .AddHeader("Content-type", "application/json") .AddJsonBody(new { fio = model.Master }))); if (!personMksResultWithClient.Success) { throw new Exception(personMksResultWithClient.Data); } repair.Master = long.Parse(personMksResultWithClient.Data); await _context.SaveChangesAsync(); }