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

            try
            {
                OrgUnitRegistrationExtended toRemove = new OrgUnitRegistrationExtended()
                {
                    Uuid = uuid
                };

                orgUnitDao.Save(toRemove, OperationType.DELETE, cvr);
            }
            catch (Exception ex)
            {
                log.Error("Failed to save OrgUnit", ex);

                return(BadRequest(ex.Message));
            }

            return(Ok());
        }
示例#2
0
        private static void testWriteReadOUThroughDB()
        {
            OrgUnitDao dao = new OrgUnitDao();

            OrgUnitRegistration registration = new OrgUnitRegistration();

            registration.Name = "Navn";
            registration.Uuid = GetFreshUuid();
            registration.ContactPlaces.Add(new BusinessLayer.DTO.V1_1.ContactPlace()
            {
                OrgUnitUuid = GetFreshUuid(),
                Tasks       = new List <string>()
                {
                    GetFreshUuid(), GetFreshUuid(), GetFreshUuid()
                }
            });
            registration.ContactPlaces.Add(new BusinessLayer.DTO.V1_1.ContactPlace()
            {
                OrgUnitUuid = GetFreshUuid(),
                Tasks       = new List <string>()
                {
                    GetFreshUuid(), GetFreshUuid()
                }
            });

            // save OU with 2 ContactPlaces with 2 and 3 Tasks associated
            dao.Save(registration, OperationType.UPDATE);

            // read and see that we get the expected back
            OrgUnitRegistrationExtended fromDaoRegistration = dao.GetOldestEntry();
        }
示例#3
0
        public IHttpActionResult Remove(string uuid)
        {
            OrgUnitRegistrationExtended toRemove = new OrgUnitRegistrationExtended();

            toRemove.Uuid = uuid;

            try
            {
                orgUnitDao.Save(toRemove, OperationType.DELETE);

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

            return(BadRequest());
        }