public void convert2DTO_hasBizEntitySchemaObj_willSetfirstbizEntitySchemaIdNotTo0() { BizEntityHelper o = new BizEntityHelper(db); OrgSchema orgSchema = db.orgSchemas.FirstOrDefault(); BizEntity bizEntity = orgSchema. bizEntityRelationOnOrgSchemas.FirstOrDefault().bizEntityChild; BizEntityDTO bizEntityDTO = o.convert2DTO(bizEntity); Assert.AreNotEqual(0, bizEntityDTO.firstbizEntitySchemaId); Assert.IsNotNull(bizEntityDTO.firstbizEntitySchemaName); }
public IHttpActionResult Get(int id) { var obj = db.bizEntities.Find(id); if (obj == null) { return(NotFound()); } var bizEntityHelper = new BizEntityHelper(); return(Ok(bizEntityHelper.convert2DTO(obj))); }
public void convert2DTO_noBizEntitySchemaObj_willSetfirstbizEntitySchemaIdTo0() { BizEntityHelper o = new BizEntityHelper(db); BizEntity bizEntity = o.createObject(); bizEntity.name = "Integration_Test_XXXYYYZZZ"; OrgSchema orgSchema = db.orgSchemas.FirstOrDefault(); BizEntity bizParentEntity = orgSchema. bizEntityRelationOnOrgSchemas.FirstOrDefault().bizEntityChild; o.saveCreatedObject(orgSchema, bizEntity, bizParentEntity); BizEntityDTO bizEntityDTO = o.convert2DTO(bizEntity); Assert.AreEqual(0, bizEntityDTO.firstbizEntitySchemaId); Assert.IsNull(bizEntityDTO.firstbizEntitySchemaName); }
public IHttpActionResult Delete(int id) { var obj = db.bizEntities.Find(id); if (obj == null) { return(NotFound()); } var bizEntityHelper = new BizEntityHelper(db); try { //OrgMgmtDBHelper.removeBizEntity(id, db); bizEntityHelper.removeObject(id); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok(bizEntityHelper.convert2DTO(obj))); }
public IHttpActionResult Post([FromUri] int orgSchemaId, [FromUri] int bizEntityParentId, BizEntity value) { var bizEntityParent = db.bizEntities.Find(bizEntityParentId); if (value == null || !ModelState.IsValid) { return(BadRequest(ModelState)); } var orgSchemaHelper = new OrgSchemaHelper(db); //if (!OrgMgmtDBHelper.isOrgSchemaExists(orgSchemaId, db) || if (!orgSchemaHelper.isObjectExists(orgSchemaId) || (bizEntityParentId > 0 && bizEntityParent == null)) { ModelState.AddModelError( string.Empty, "数据错误(invalid orgSchemaId or bizEntityParentId>0 && bizEntityParent==null)!"); return(BadRequest(ModelState)); } var bizEntityHelper = new BizEntityHelper(db); try { //OrgMgmtDBHelper.saveCreatedBizEntity( // db.orgSchemas.Find(orgSchemaId), value, bizEntityParent, db); bizEntityHelper.saveCreatedObject(db.orgSchemas.Find(orgSchemaId), value, bizEntityParent); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok(bizEntityHelper.convert2DTO(value))); }