Пример #1
0
 public List <Model.TblProduct> GetRecords(Model.FilterProductLogs filters)
 {
     try
     {
         using (var context = new Model.SolutionsOnlineSellingEntities())
         {
             return(context.TblProduct.ToPagedList(filters.PageNumber, filters.PageSize));;
         }
     }
     catch
     {
         return(new List <Model.TblProduct>());
     }
 }
Пример #2
0
 public Model.TblCalendar GetCalendar(int calendarId)
 {
     try
     {
         using (var context = new Model.SolutionsOnlineSellingEntities())
         {
             return(context.TblCalendar.Where(s => s.EventId == calendarId).FirstOrDefault());
         }
     }
     catch (Exception ex)
     {
         Helpers.Logger.LogException(ex, false);
         return(null);
     }
 }
Пример #3
0
 public List <T> SelectQuery(string query)
 {
     try
     {
         using (var context = new Model.SolutionsOnlineSellingEntities())
         {
             var requiredList = context.Database.SqlQuery <T>(query).ToList <T>();
             return(requiredList);
         }
     }
     catch (Exception ex)
     {
         ErrorMessage = ex.Message;
         return(new List <T>());
     }
 }
Пример #4
0
        public bool ManageCalendar(TblCalendar model)
        {
            try
            {
                using (var context = new Model.SolutionsOnlineSellingEntities())
                {
                    context.Entry(model).State = model.EventId == 0 ? EntityState.Added : EntityState.Modified;
                    context.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                Helpers.Logger.LogException(ex, true);
                return(false);
            }
        }
Пример #5
0
        public List <Model.TblProduct> GetRecords(bool?activeStatus = null)
        {
            try
            {
                using (var context = new Model.SolutionsOnlineSellingEntities())
                {
                    if (activeStatus.HasValue == true)
                    {
                        return(context.TblProduct.Where(s => s.Active == activeStatus.Value).ToList());
                    }

                    return(context.TblProduct.ToList());
                }
            }
            catch
            {
                return(new List <Model.TblProduct>());
            }
        }
Пример #6
0
        public int GetCounts(bool?activeStatus = null)
        {
            try
            {
                using (var context = new Model.SolutionsOnlineSellingEntities())
                {
                    if (activeStatus.HasValue == true)
                    {
                        return(context.TblProduct.Where(s => s.Active == activeStatus.Value).Count());
                    }

                    return(context.TblProduct.Count());
                }
            }
            catch
            {
                return(0);
            }
        }
Пример #7
0
        public int GetCounts(bool? activeStatus = null)
        {
            try
            {
                using (var context = new Model.SolutionsOnlineSellingEntities())
                {
                    if (activeStatus.HasValue == true)
                    {
                        return context.TblCategory.Where(s => s.Active == activeStatus.Value).Count();
                    }

                    return context.TblCategory.Count();
                }
            }
            catch (Exception ex)
            {
                Helpers.Logger.LogException(ex, false);
                return 0;
            }
        }
Пример #8
0
        public List <Model.TblCalendar> GetCalendar(bool?activeStatus = null)
        {
            try
            {
                using (var context = new Model.SolutionsOnlineSellingEntities())
                {
                    if (activeStatus.HasValue == true)
                    {
                        return(context.TblCalendar.Where(s => s.IsActive == activeStatus.Value).ToList());
                    }

                    return(context.TblCalendar.ToList());
                }
            }
            catch (Exception ex)
            {
                Helpers.Logger.LogException(ex, false);
                return(null);
            }
        }
Пример #9
0
        public List <T> SelectQuery(string columnArray, string tableName, string whereClause = null, string orderClause = null)
        {
            try
            {
                using (var context = new Model.SolutionsOnlineSellingEntities())
                {
                    if (string.IsNullOrEmpty(columnArray) == true)
                    {
                        columnArray = "*";
                    }

                    //Querying with Object Services and Entity SQL
                    string sqlString = string.Format("SELECT {0} FROM SolutionsOnlineSellingEntities.{1} ", columnArray, tableName);

                    if (string.IsNullOrEmpty(whereClause) == false)
                    {
                        sqlString = string.Format("{0} WHERE {1}", sqlString, whereClause);
                    }

                    if (string.IsNullOrEmpty(orderClause) == false)
                    {
                        sqlString = string.Format("{0} ORDER BY {1}", sqlString, orderClause);
                    }



                    var objctx = (context as IObjectContextAdapter).ObjectContext;

                    ObjectQuery <T> queryList    = objctx.CreateQuery <T>(sqlString);
                    var             requiredList = queryList.ToList <T>();

                    return(requiredList);
                }
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                return(new List <T>());
            }
        }