public void Update(UpdateNRelationTypeIncomeModel model, Guid?companyId) { var companiesId = _companyRepository.GetAll().Where(c => c.CreatedByCompanyId == companyId).Select(cc => cc.Id).ToList(); if (_nRelationTypeRepository.Any(nr => nr.Id != model.Id && nr.Name == model.Name && (nr.CreatedByCompanyId == companyId || companiesId.Contains(nr.CreatedByCompanyId))) ) { throw new AlreadyExistException(); } var dbNRelationType = _nRelationTypeRepository.GetSingle(nr => nr.Id == model.Id); if (dbNRelationType == null) { throw new ObjectNotFoundException(); } dbNRelationType.Name = model.Name; _nRelationTypeRepository.Update(dbNRelationType); }
public IActionResult Update([FromBody] UpdateNRelationTypeIncomeModel model) { _nRelationTypeService.Update(model, CurrentUser.CompanyId); return(OkResult()); }