public void Delete(DeleteObjectsIncomeModel model, Guid?companyId) { var dbNRelationTypes = _nRelationTypeRepository .GetAll(nr => model.Ids.Contains(nr.Id)); if (dbNRelationTypes.Count != model.Ids.Count) { throw new ObjectNotFoundException(); } if (dbNRelationTypes.Any(t => t.CreatedByCompanyId != companyId)) { throw new NonAccessibleResourceException(); } dbNRelationTypes = dbNRelationTypes.Where(nr => !nr.Companies.Any()).ToList(); var isExceptionThrown = dbNRelationTypes.Count != model.Ids.Count; _nRelationTypeRepository.RemoveRange(dbNRelationTypes); if (isExceptionThrown) { throw new BoundedObjectsException($"{StaticResource.BindedEntities} Tasks"); } }
public IActionResult Delete([FromBody] DeleteObjectsIncomeModel model) { _nRelationTypeService.Delete(model, CurrentUser.CompanyId); return(OkResult()); }