using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using CK.SCP.Models; using CK.SCP.Models.ScpEntity; using CK.SCP.Utils; using System.Data.Entity.Core; using CK.SCP.Models.Enums; namespace CK.SCP.Controller { public class SCP_V_TA_VEND_PART_CONTROLLER { public static void Get_V_TA_VEND_PART_List(V_TA_VEND_PART p_entity,Action>> p_action) { ResultObject> _ret = new ResultObject>(); try { using (ScpEntities db = EntitiesFactory.CreateScpInstance()) { IQueryable q = db.V_TA_VEND_PART; if (p_entity.UID != 0) { q = q.Where(p => p.UID == p_entity.UID); } if (!string.IsNullOrEmpty(p_entity.VendId)) { q = q.Where(p => p.VendId.Contains(p_entity.VendId)); } if (!string.IsNullOrEmpty(p_entity.PartCode)) { q = q.Where(p => p.PartCode.Contains(p_entity.PartCode)); } if (p_entity.VendPackQty != 0) { q = q.Where(p => p.VendPackQty == p_entity.VendPackQty); } if (!string.IsNullOrEmpty(p_entity.PoUnit)) { q = q.Where(p => p.PoUnit.Contains(p_entity.PoUnit)); } if (!string.IsNullOrEmpty(p_entity.Site)) { q = q.Where(p => p.Site.Contains(p_entity.Site)); } if (p_entity.TransportationTime != null) { q = q.Where(p => p.TransportationTime == p_entity.TransportationTime); } if (!string.IsNullOrEmpty(p_entity.VendName)) { q = q.Where(p => p.VendName.Contains(p_entity.VendName)); } if (!string.IsNullOrEmpty(p_entity.PartDesc1)) { q = q.Where(p => p.PartDesc1.Contains(p_entity.PartDesc1)); } if (!string.IsNullOrEmpty(p_entity.PartDesc2)) { q = q.Where(p => p.PartDesc2.Contains(p_entity.PartDesc2)); } if (!string.IsNullOrEmpty(p_entity.ProjectId)) { q = q.Where(p => p.ProjectId.Contains(p_entity.ProjectId)); } if (!string.IsNullOrEmpty(p_entity.PartDesc)) { q = q.Where(p => p.PartDesc.Contains(p_entity.PartDesc)); } if (p_entity.UserInAddress != null && p_entity.UserInAddress.Count > 0) { q = q.Where(p => p_entity.UserInAddress.Contains(p.Site)); } if (p_entity.UserInVendIds != null && p_entity.UserInVendIds.Count > 0) { q = q.Where(p => p_entity.UserInVendIds.Contains(p.VendId)); } _ret.State = ReturnStatus.Succeed; _ret.Result = q; p_action(_ret); } } catch (Exception e) { _ret.State = ReturnStatus.Failed; _ret.ErrorList.Add(e); LogHelper.Writlog(LogHelper.LogType.Error, typeof(V_TA_VEND_PART), "Get_V_TA_VEND_PART_List", e.Message); throw e; } } } }