Example #1
0
 /// <summary>
 /// RoutingWithMaterialFile
 /// </summary>
 /// <param name="filter"></param>
 /// <returns></returns>
 public RoutingWithMaterialFileViewModel GetRoutingWithMaterialFileView(RoutingWithMaterialFileFilterModel filter)
 {
     return(RoutingWithMaterialFileBLL.GetRoutingWithMaterialFileView(filter));
 }
        public static RoutingWithMaterialFileViewModel GetRoutingWithMaterialFileView(RoutingWithMaterialFileFilterModel filter)
        {
            ACTION = "GetRoutingWithMaterialFileView(RoutingWithMaterialFileFilterModel)";
            try
            {
                ResponseModel response    = new ResponseModel();
                int           totalRecord = 0;

                var model = RoutingWithMaterialFileDAL.GetRoutingWithMaterialFileList(filter, ref totalRecord, ref response);
                filter.Pagination.TotalRecord = totalRecord;

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

                filter.Pagination = pagination;

                return(new RoutingWithMaterialFileViewModel()
                {
                    Action = ACTION,
                    Source = SOURCE,
                    Status = response.Status,
                    Message = response.Message,
                    List = model,
                    Filter = filter
                });
            }
            catch (Exception ex)
            {
                return(new RoutingWithMaterialFileViewModel()
                {
                    Action = ACTION,
                    Source = SOURCE,
                    Status = false,
                    Message = ex.Message,
                    List = null,
                    Filter = filter
                });
            }
        }
Example #3
0
        public static List <RoutingWithMaterialFileModel> GetRoutingWithMaterialFileList(RoutingWithMaterialFileFilterModel filter, ref int totalRecord, ref ResponseModel response)
        {
            ACTION = "GetRoutingWithMaterialFileList(RoutingWithMaterialFileFilterModel)";
            try
            {
                using (UTMMABCDBEntities context = new UTMMABCDBEntities())
                {
                    filter.RoutingWithMaterialFileIDs = filter.RoutingWithMaterialFileIDs != null ? filter.RoutingWithMaterialFileIDs : new int[] { };
                    var IQuery = context.USR_TMMA_ROUTING_WITH_MATERIAL_FILE
                                 .Where(o =>
                                        (!string.IsNullOrEmpty(filter.Keywords) ?
                                         (o.RecObjectName.Contains(filter.Keywords)) ||
                                         (o.CreatedBy.Contains(filter.Keywords))
                        : true) &&
                                        (filter.RoutingWithMaterialFileID.HasValue ? o.RoutingWithMaterialFileID == filter.RoutingWithMaterialFileID.Value : true) &&
                                        (filter.RoutingWithMaterialFileIDs.Count() > 0 ? filter.RoutingWithMaterialFileIDs.Contains(o.RoutingWithMaterialFileID) : 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();

                    List <USR_TMMA_ROUTING_WITH_MATERIAL_FILE> list = filter.Pagination.IsPaging ? IQuery.OrderBy(o => o.CreatedDate).Skip(filter.Pagination.Skip).Take(filter.Pagination.Take).ToList() : IQuery.ToList();

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