Beispiel #1
0
        public async Task <JsonResult> DeleteEquipmentFromModel([FromBody] Model.EquipmentModel equipmentModel)
        {
            await CheckPermission();

            var mr = new ModelRepository(_logger);
            var er = new EquipmentRepository(_logger);
            var eq = await er.GetCheckListByEquipmentModelId(equipmentModel.Id);

            if (eq == null)
            {
                throw new Exception("EquipmentModel not found");
            }

            //if (!er.IsEquipmentChecklistsEmpty(eq))
            //    throw new Exception("Checklists not empty");
            await er.DeleteEquipmentWithCheckLists(eq);

            await mr.DeleteEquipmentFromModel(equipmentModel.Id);

            return(Json(new { message = "Delete OK" }));
        }