public static WorkCenterFileViewModel GetWorkCenterFileView(WorkCenterFileFilterModel filter) { ACTION = "GetWorkCenterFileView(WorkCenterFileFilterModel)"; try { ResponseModel response = new ResponseModel(); int totalRecord = 0; decimal lastVersion = 0; var model = WorkCenterFileDAL.GetWorkCenterFileList(filter, ref totalRecord, ref response, ref lastVersion); filter.Pagination.TotalRecord = totalRecord; PaginationModel pagination = new PaginationModel(totalRecord, filter.Pagination.Page, filter.Pagination.Take); filter.Pagination = pagination; filter.LastWorkCenterFileVersion = lastVersion; return(new WorkCenterFileViewModel() { Action = ACTION, Source = SOURCE, Status = response.Status, Message = response.Message, List = model, Filter = filter }); } catch (Exception ex) { return(new WorkCenterFileViewModel() { Action = ACTION, Source = SOURCE, Status = false, Message = ex.Message, List = null, Filter = filter }); } }
public static List <WorkCenterFileModel> GetWorkCenterFileList(WorkCenterFileFilterModel filter, ref int totalRecord, ref ResponseModel response, ref decimal lastVersion) { ACTION = "GetWorkCenterFileList(WorkCenterFileFilterModel)"; try { using (UTMMABCDBEntities context = new UTMMABCDBEntities()) { filter.WorkCenterFileIDs = filter.WorkCenterFileIDs != null ? filter.WorkCenterFileIDs : new int[] { }; var IQuery = context.USR_TMMA_WORK_CENTER_FILE .Where(o => (!string.IsNullOrEmpty(filter.Keywords) ? (o.RecObjectName.Contains(filter.Keywords)) || (o.CreatedBy.Contains(filter.Keywords)) : true) && (filter.WorkCenterFileID.HasValue ? o.WorkCenterFileID == filter.WorkCenterFileID.Value : true) && (filter.WorkCenterFileIDs.Count() > 0 ? filter.WorkCenterFileIDs.Contains(o.WorkCenterFileID) : true) && (!string.IsNullOrEmpty(filter.RecObjectName) ? filter.CreatedBy.Contains(o.RecObjectName) : true) && (filter.ProductsTypeID.HasValue ? o.ProductsTypeID == filter.ProductsTypeID.Value : true) && (filter.IsActive.HasValue ? o.IsActive == 1 : true) ); totalRecord = IQuery.Count(); var lists = filter.Sort == "asc" ? filter.Order == "RecObjectName" ? IQuery.OrderBy(o => o.RecObjectName) : filter.Order == "UserSAP" ? IQuery.OrderBy(o => o.UserSAP) : filter.Order == "Version" ? IQuery.OrderBy(o => o.WorkCenterFileVersion) : filter.Order == "Status" ? IQuery.OrderBy(o => o.WorkCenterFileStatus) : filter.Order == "CreatedBy" ? IQuery.OrderBy(o => o.CreatedBy) : filter.Order == "CreatedDate" ? IQuery.OrderBy(o => o.CreatedDate) : IQuery.OrderBy(o => o.CreatedDate) : filter.Order == "RecObjectName" ? IQuery.OrderByDescending(o => o.RecObjectName) : filter.Order == "UserSAP" ? IQuery.OrderByDescending(o => o.UserSAP) : filter.Order == "Version" ? IQuery.OrderByDescending(o => o.WorkCenterFileVersion) : filter.Order == "Status" ? IQuery.OrderByDescending(o => o.WorkCenterFileStatus) : filter.Order == "CreatedBy" ? IQuery.OrderByDescending(o => o.CreatedBy) : filter.Order == "CreatedDate" ? IQuery.OrderByDescending(o => o.CreatedDate) : IQuery.OrderByDescending(o => o.CreatedDate); lastVersion = IQuery.OrderByDescending(o => o.WorkCenterFileVersion).FirstOrDefault().WorkCenterFileVersion.GetValueOrDefault(); List <USR_TMMA_WORK_CENTER_FILE> list = filter.Pagination.IsPaging ? lists.Skip(filter.Pagination.Skip).Take(filter.Pagination.Take).ToList() : lists.ToList(); List <WorkCenterFileModel> mList = Mapping(list); response = new ResponseModel() { Source = SOURCE, Action = ACTION, Status = true, Message = "Success" }; return(mList); } } catch (Exception ex) { totalRecord = 0; response = new ResponseModel() { Source = SOURCE, Action = ACTION, Status = false, Message = ex.Message }; return(null); } }
/// <summary> /// Monomer Work Center /// </summary> /// <param name="filter"></param> /// <returns></returns> public WorkCenterFileViewModel GetWorkCenterFileView(WorkCenterFileFilterModel filter) { return(WorkCenterFileBLL.GetWorkCenterFileView(filter)); }