Ejemplo n.º 1
0
        public void AnatomyManager_DeleteAnatomy()
        {
            AnatomyManager m = new AnatomyManager(new TreeMonDbContext(connectionKey));
            Anatomy        s = new Anatomy()
            {
                AccountId   = "a",
                Name        = "DELETERECORD",
                CreatedBy   = "TESTUSER",
                DateCreated = DateTime.UtcNow
            };

            m.Insert(s);

            //Test the delete flag
            Assert.IsTrue(m.DeleteAnatomy(s) > 0);
            m.GetAnatomy("DELETERECORD");
            Anatomy d = m.GetAnatomy("DELETERECORD");

            Assert.IsNotNull(d);
            Assert.IsTrue(d.Deleted == true);


            Assert.IsTrue(m.DeleteAnatomy(s, true) > 0);
            d = m.GetAnatomy("DELETERECORD");
            Assert.IsNull(d);
        }
Ejemplo n.º 2
0
        public ServiceResult AddAnatomy(Anatomy s)
        {
            if (CurrentUser == null)
            {
                return(ServiceResponse.Error("You must be logged in to access this function."));
            }


            if (string.IsNullOrWhiteSpace(s.AccountUUID) || s.AccountUUID == SystemFlag.Default.Account)
            {
                s.AccountUUID = CurrentUser.AccountUUID;
            }

            if (string.IsNullOrWhiteSpace(s.CreatedBy))
            {
                s.CreatedBy = CurrentUser.UUID;
            }

            if (s.DateCreated == DateTime.MinValue)
            {
                s.DateCreated = DateTime.UtcNow;
            }

            AnatomyManager anatomyManager = new AnatomyManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter);

            return(anatomyManager.Insert(s, true));
        }
Ejemplo n.º 3
0
        public ServiceResult Insert(AnatomyTag n)
        {
            if (CurrentUser == null)
            {
                return(ServiceResponse.Error("You must be logged in to access this function."));
            }


            if (string.IsNullOrWhiteSpace(n.AccountUUID))
            {
                n.AccountUUID = CurrentUser.AccountUUID;
            }

            if (string.IsNullOrWhiteSpace(n.CreatedBy))
            {
                n.CreatedBy = CurrentUser.UUID;
            }

            if (n.DateCreated == DateTime.MinValue)
            {
                n.DateCreated = DateTime.UtcNow;
            }

            AnatomyManager AnatomyTagsManager = new AnatomyManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter);

            return(AnatomyTagsManager.Insert(n, true));
        }
Ejemplo n.º 4
0
        public void AnatomyManager_Insert()
        {
            AnatomyManager m = new AnatomyManager(new TreeMonDbContext(connectionKey));

            Assert.AreEqual(
                m.Insert(new Anatomy()
            {
                AccountId   = "a",
                Name        = "TESTRECORD",
                DateCreated = DateTime.UtcNow
            })
                .Code, 200);

            //won't allow a duplicate name
            Assert.AreEqual(
                m.Insert(new Anatomy()
            {
                AccountId   = "a",
                Name        = "TESTRECORD",
                DateCreated = DateTime.UtcNow
            })
                .Code, 500);
        }
Ejemplo n.º 5
0
        public void AnatomyManager_GetAnatomy()
        {
            AnatomyManager m  = new AnatomyManager(new TreeMonDbContext(connectionKey));
            ServiceResult  sr = m.Insert(new Anatomy()
            {
                AccountId   = "a",
                Name        = "ALPHA",
                DateCreated = DateTime.UtcNow
            }, false);

            Assert.AreEqual(sr.Code, 200, sr.Message);
            Anatomy s = m.GetAnatomy("ALPHA");

            Assert.IsNotNull(s);
        }
Ejemplo n.º 6
0
        public void AnatomyManager_GetAnatomyTagBy()
        {
            AnatomyManager m  = new AnatomyManager(new TreeMonDbContext(connectionKey));
            ServiceResult  sr = m.Insert(new AnatomyTag()
            {
                AccountId   = "a",
                Name        = "TESTRECORD",
                DateCreated = DateTime.UtcNow
            }, false);

            AnatomyTag s = m.GetAnatomyTag("TESTRECORD");

            Assert.IsNotNull(s);
            AnatomyTag suid = m.GetAnatomyTagBy(s.UUID);

            Assert.IsNotNull(suid);
        }
Ejemplo n.º 7
0
        public void AnatomyManager_UpdateAnatomy()
        {
            AnatomyManager m = new AnatomyManager(new TreeMonDbContext(connectionKey));

            m.Insert(new Anatomy()
            {
                AccountId = "a",
                Name      = "TESTRECORD",
                UUID      = Guid.NewGuid().ToString("N")
            });
            Anatomy s = m.GetAnatomy("TESTRECORD");

            s.Name = "UPDATEDRECORD";

            Assert.AreEqual(m.UpdateAnatomy(s).Code, 200);
            Anatomy u = m.GetAnatomy("UPDATEDRECORD");

            Assert.IsNotNull(u);
        }