Esempio n. 1
0
        public IActionResult Get(int id)
        {
            if (id <= 0)
            {
                return(BadRequest("Invalid id provided"));
            }
            var response = organizationTypeService.Get(id);

            return(Ok(response));
        }
        public IActionResult Get(Guid id)
        {
            if (_organizationTypeService.Contains(id))
            {
                var organizationType = _organizationTypeService.Get(id);

                var organizationTypeViewModel = _organizationTypeModelBuilder.BuildNew(organizationType);

                return(Ok(organizationTypeViewModel));
            }
            else
            {
                return(NotFound());
            }
        }
        public OrganizationViewModel BuildNew(Organization organization)
        {
            var organizationType   = _organizationTypeService.Get(organization.OrganizationTypeId);
            var parentOrganization = _organizationService.Get(organization.ParentOrganizationId.Value);

            var organizationTypeViewModel   = _organizationTypeModelBuilder.BuildNew(organizationType);
            var parentOrganizationViewModel = BuildNew(parentOrganization);

            var organizationViewModel = new OrganizationViewModel()
            {
                Id                 = organization.Id,
                Title              = organization.Title,
                TitleShort         = organization.TitleShort,
                ParentOrganization = parentOrganizationViewModel,
                OrganizationType   = organizationTypeViewModel
            };

            return(organizationViewModel);
        }