public ActionResult GetSmartContracts() { try { IEnumerable <SmartContractModel> contracts = null; var typeUser = (ETypeUser)Convert.ToInt32(User.FindFirst(ClaimTypes.Role)?.Value); switch (typeUser) { case ETypeUser.Customer: contracts = _service.GetSmartContracts(); break; case ETypeUser.Company: int companyId = Convert.ToInt32(User.FindFirst(ClaimTypes.NameIdentifier)?.Value); contracts = _service.GetSmartContracts(companyId); break; case ETypeUser.Employee: break; } if (contracts == null) { return(NotFound()); } var contractsView = _mapper.Map <IEnumerable <SmartContractView> >(contracts); return(Ok(contractsView)); } catch (Exception e) { return(StatusCode(500, e)); } }
public IEnumerable <SmartContractViews> GetSmartContracts(long id, string title = null) { var contract = smartContractService.GetSmartContracts(id); return(contract?.ToSmartContractView()); }