Example #1
0
        public IHttpActionResult SetParent(
            int orgSchemaId, int id, int bizEntityIdParent)
        {
            var bizEntityParent = db.bizEntities.Find(bizEntityIdParent);
            var bizEntityHelper = new BizEntityHelper(db);

            try
            {
                //OrgMgmtDBHelper.setParentBizEntity(id, bizEntityParent, orgSchemaId, db);
                bizEntityHelper.setParentBizEntity(id, bizEntityParent, orgSchemaId);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
        public void setParentBizEntity_validObjWithValidParent_willExist()
        {
            BizEntityHelper o         = new BizEntityHelper(db);
            BizEntity       bizEntity = o.createObject();

            bizEntity.name = "Integration_Test_XXXYYYZZZ";
            OrgSchema orgSchema       = db.orgSchemas.FirstOrDefault();
            BizEntity bizEntityParent = o.createObject();

            bizEntityParent.name = "Integration_Test_Temp_Parent";
            o.saveCreatedObject(orgSchema, bizEntityParent, null);
            o.saveCreatedObject(orgSchema, bizEntity, null);

            o.setParentBizEntity(bizEntity.bizEntityId, bizEntityParent, orgSchema.orgSchemaId);

            Assert.AreEqual(1, db.bizEntityRelationOnOrgSchemas.Where(
                                ber => ber.assistOrgSchemaId == orgSchema.orgSchemaId &&
                                ber.bizEntityIdChild == bizEntity.bizEntityId &&
                                ber.bizEntityIdParent == bizEntityParent.bizEntityId
                                ).Count());
        }