Пример #1
0
        public static ProductionVersionFileViewModel GetProductionVersionFileView(ProductionVersionFileFilterModel filter)
        {
            ACTION = "GetProductionVersionFileView(ProductionVersionFileFilterModel)";
            try
            {
                ResponseModel response    = new ResponseModel();
                int           totalRecord = 0;
                decimal       lastVersion = 0;

                var model = ProductionVersionFileDAL.GetProductionVersionFileList(filter, ref totalRecord, ref response, ref lastVersion);
                filter.Pagination.TotalRecord           = totalRecord;
                filter.LastProductionVersionFileVersion = lastVersion;

                PaginationModel pagination = new PaginationModel(totalRecord, filter.Pagination.Page, filter.Pagination.Take);

                filter.Pagination = pagination;

                return(new ProductionVersionFileViewModel()
                {
                    Action = ACTION,
                    Source = SOURCE,
                    Status = response.Status,
                    Message = response.Message,
                    List = model,
                    Filter = filter
                });
            }
            catch (Exception ex)
            {
                return(new ProductionVersionFileViewModel()
                {
                    Action = ACTION,
                    Source = SOURCE,
                    Status = false,
                    Message = ex.Message,
                    List = null,
                    Filter = filter
                });
            }
        }
Пример #2
0
 /// <summary>
 /// Monomer Production Version
 /// </summary>
 /// <param name="filter"></param>
 /// <returns></returns>
 public ProductionVersionFileViewModel GetProductionVersionFileView(ProductionVersionFileFilterModel filter)
 {
     return(ProductionVersionFileBLL.GetProductionVersionFileView(filter));
 }
        public static List <ProductionVersionFileModel> GetProductionVersionFileList(ProductionVersionFileFilterModel filter, ref int totalRecord, ref ResponseModel response, ref decimal lastVersion)
        {
            ACTION = "GetProductionVersionFileList(ProductionVersionFileFilterModel)";
            try
            {
                using (UTMMABCDBEntities context = new UTMMABCDBEntities())
                {
                    filter.ProductionVersionFileIDs = filter.ProductionVersionFileIDs != null ? filter.ProductionVersionFileIDs : new int[] { };
                    var IQuery = context.USR_TMMA_PRODUCTION_VERSION_FILE
                                 .Where(o =>
                                        (!string.IsNullOrEmpty(filter.Keywords) ?
                                         (o.RecObjectName.Contains(filter.Keywords)) ||
                                         (o.CreatedBy.Contains(filter.Keywords))
                        : true) &&
                                        (filter.ProductionVersionFileID.HasValue ? o.ProductionVersionFileID == filter.ProductionVersionFileID.Value : true) &&
                                        (filter.ProductionVersionFileIDs.Count() > 0 ? filter.ProductionVersionFileIDs.Contains(o.ProductionVersionFileID) : 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.ProductionVersionFileVersion)
                        : filter.Order == "Status" ? IQuery.OrderBy(o => o.ProductionVersionFileStatus)
                        : 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.ProductionVersionFileVersion)
                        : filter.Order == "Status" ? IQuery.OrderByDescending(o => o.ProductionVersionFileStatus)
                        : 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.ProductionVersionFileVersion).FirstOrDefault().ProductionVersionFileVersion.GetValueOrDefault();

                    List <USR_TMMA_PRODUCTION_VERSION_FILE> list = filter.Pagination.IsPaging ? IQuery.Skip(filter.Pagination.Skip).Take(filter.Pagination.Take).ToList() : IQuery.ToList();

                    List <ProductionVersionFileModel> 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);
            }
        }