Пример #1
0
        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 }));
            }
        }
Пример #2
0
        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;
            }
        }