public async Task <IActionResult> AddDefects([FromBody] EquipmentWithDefectsModel model) { try { await _equipmentRepository.AddDefects(long.Parse(model.EquipmentId), long.Parse(model.RepairId), model.Defects); return(Json( new { Success = true, Data = "Ok" })); } catch (Exception exception) { return(Json(new { Success = false, exception.Message })); } }
public async Task <IActionResult> AddDefectsForEquipment(EquipmentWithDefectsModel model) { try { ViewBag.Role = await InitRole(); var equipmentMksResult = JsonConvert.DeserializeObject <MksResponseResult>( await RequestExecutor.ExecuteRequest(Scope.EquipmentMksUrl, new RestRequest("/AddDefects", Method.POST) .AddHeader("Content-type", "application/json") .AddJsonBody(JsonConvert.SerializeObject(model)))); if (!equipmentMksResult.Success) { throw new Exception(equipmentMksResult.Data); } return(RedirectToAction("Index", "Equipment")); } catch (Exception exception) { ModelState.AddModelError(nameof(exception), exception.ToString()); throw; } }