/// ประเภทอาหารสัตว์ public HttpResponseMessage loadAnimalsupplies() { try { string animalsupplieroid = HttpContext.Current.Request.Form["animalsupplieroid"].ToString(); // string animalsuppliertypeoid = HttpContext.Current.Request.Form["animalsuppliertypeoid"].ToString(); XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(AnimalSupplieType)); List <AnimalSupplieType_Model> list = new List <AnimalSupplieType_Model>(); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); IList <AnimalSupplieType> collection = ObjectSpace.GetObjects <AnimalSupplieType>(CriteriaOperator.Parse(" GCRecord is null and IsActive = 1 and [AnimalSupplie.oid] = ? ", animalsupplieroid)); foreach (AnimalSupplieType row in collection) { AnimalSupplieType_Model model = new AnimalSupplieType_Model(); model.animalsupplieoid = row.AnimalSupplie.Oid.ToString(); model.AnimalSupplieTypeOid = row.Oid.ToString(); model.SupplietypeName = row.SupplietypeName; model.AnimalSupplieName = row.AnimalSupplie.AnimalSupplieName; model.SalePrice = row.SalePrice; model.IsActive = row.IsActive; list.Add(model); } return(Request.CreateResponse(HttpStatusCode.OK, list)); } catch (Exception ex) { //Error case เกิดข้อผิดพลาด UserError err = new UserError(); err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = ex.Message; // Return resual return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } }
public HttpResponseMessage AnimalSupplieType_list() { try { XpoTypesInfoHelper.GetXpoTypeInfoSource(); XafTypesInfo.Instance.RegisterEntity(typeof(AnimalSupplieType)); XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null); IObjectSpace ObjectSpace = directProvider.CreateObjectSpace(); IList <AnimalSupplieType> collection = ObjectSpace.GetObjects <AnimalSupplieType>(CriteriaOperator.Parse(" GCRecord is null and IsActive = 1", null)); if (collection.Count > 0) { List <AnimalSupplieType_Model> list = new List <AnimalSupplieType_Model>(); foreach (AnimalSupplieType row in collection) { AnimalSupplieType_Model item = new AnimalSupplieType_Model(); item.AnimalSupplieTypeOid = row.Oid.ToString(); item.SupplietypeName = row.SupplietypeName; item.AnimalSupplieName = row.AnimalSupplie.AnimalSupplieName; item.SalePrice = row.SalePrice; list.Add(item); } return(Request.CreateResponse(HttpStatusCode.OK, list)); } else { UserError err = new UserError(); err.code = "-1"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = "ไม่พบข้อมูล"; return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } } catch (Exception ex) { //Error case เกิดข้อผิดพลาด UserError err = new UserError(); err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = ex.Message; // Return resual return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } }