Exemple #1
0
        public IActionResult Read(string uuid, [FromHeader] string cvr, [FromHeader] string apiKey)
        {
            if (AuthorizeAndFetchCvr(cvr, apiKey) == null)
            {
                return(Unauthorized());
            }

            if (string.IsNullOrEmpty(uuid))
            {
                return(BadRequest("uuid is null"));
            }

            try
            {
                OrgUnitRegistration registration = orgUnitService.Read(uuid);
                if (registration != null)
                {
                    return(Ok(registration));
                }
            }
            catch (RegistrationNotFoundException)
            {
                return(NotFound());
            }
            catch (Exception ex)
            {
                log.Error("Failed to read OrgUnit", ex);

                return(BadRequest(ex.Message));
            }

            return(NotFound());
        }
Exemple #2
0
        private static void TestMultipleAddresses()
        {
            var reg = OUReg();

            reg.Email       = "*****@*****.**";
            reg.PhoneNumber = "12345678";
            orgUnitService.Update(reg);

            var ou = orgUnitService.Read(reg.Uuid);

            if (!"12345678".Equals(ou.PhoneNumber))
            {
                throw new Exception("Wrong phone");
            }
            else if (!"*****@*****.**".Equals(ou.Email))
            {
                throw new Exception("Wrong email");
            }
        }
Exemple #3
0
        public IHttpActionResult Read(string uuid)
        {
            if (string.IsNullOrEmpty(uuid))
            {
                return(BadRequest());
            }

            try
            {
                OrgUnitRegistration registration = orgUnitService.Read(uuid);
                if (registration == null)
                {
                    return(NotFound());
                }

                return(Ok(registration));
            }
            catch (Exception ex)
            {
                log.Error(messages.GetOuMessage(messages.READ_FAILED), ex);

                return(InternalServerError());
            }
        }