Esempio n. 1
0
        public static Config Config()
        {
            alluneedbEntities db  = new alluneedbEntities();
            Config            tmp = db.Configs.FirstOrDefault();

            return(tmp);
        }
Esempio n. 2
0
        public ActionResult ApiInfoUser(string username)
        {
            if (username == null)
            {
                return(Json(new { Username = "", Name = "", Email = "", Phone = "", Avatar = "" }, JsonRequestBehavior.AllowGet));
            }
            var de      = new alluneedbEntities();
            var user    = de.Users.Single(p => p.Login == username);
            var avartar = "images/gallery.gif";

            if (de.MediaContents.Any(p => p.ContentObjId == user.Id))
            {
                avartar = de.MediaContents.Single(p => p.ContentObjId == user.Id).FullURL;
            }
            return(Json(new { Username = user.Login, Name = user.FullName, Email = user.EMail, Phone = user.PhoneNumber, Avatar = avartar }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
 /*
  * Method getting comment by comment ID
  * commentId: ID of product (from product detail page)
  * cms_db: Controll class from DataMode.DataStore
  */
 public ObjContentComment GetCommentById(long commentId, Ctrl cms_db, long userId)
 {
     try
     {
         ObjContentComment comment = new ObjContentComment();
         string            query   = "SELECT cm.*, mc.ThumbURL AS UserAvatar, ur.Id AS UserId FROM ContentComment cm LEFT JOIN dbo.[User] ur "
                                     + "ON cm.EmailAddress = ur.EMail LEFT JOIN MediaContent mc ON ur.Id = mc.ContentObjId WHERE cm.CommentId = '" + commentId + "' ORDER BY cm.CrtdDT DESC";
         using (var context = new alluneedbEntities())
         {
             System.Data.Entity.Infrastructure.DbRawSqlQuery <ObjContentComment> data = db.Database.SqlQuery <ObjContentComment>(query);
             comment = data.FirstOrDefault();
         }
         return(comment);
     }
     catch (Exception ex)
     {
         Core core = new Core();
         core.AddToExceptionLog("GetCommentById", "ProductController", "Get comment by ID Error: " + ex.Message, userId);
         return(null);
     }
 }
Esempio n. 4
0
        /*
         * Method getting latest comment of a product
         * productId: ID of product (from product detail page)
         * objTypeId: Object type id (This can retrive comment for many kind like: product, media, news, videos etc...)
         * cms_db: Controll class from DataMode.DataStore
         */
        public List <ObjContentComment> GetLatestCommentByProductId(int productId, int objTypeId, Ctrl cms_db)
        {
            Product product = cms_db.GetObjProductById(productId);

            if (product != null)
            {
                try
                {
                    List <ObjContentComment> comments = new List <ObjContentComment>();
                    string query = "SELECT top (1) cm.*, mc.ThumbURL AS UserAvatar, ur.Id AS UserId FROM ContentComment cm LEFT JOIN dbo.[User] ur "
                                   + "ON cm.EmailAddress = ur.EMail LEFT JOIN MediaContent mc ON ur.Id = mc.ContentObjId WHERE cm.ContentObjId = '" + productId + "' ORDER BY cm.CrtdDT DESC";
                    using (var context = new alluneedbEntities())
                    {
                        System.Data.Entity.Infrastructure.DbRawSqlQuery <ObjContentComment> data = db.Database.SqlQuery <ObjContentComment>(query);
                        comments = data.ToList();
                    }
                    if (comments.Count > 0)
                    {
                        return(comments);
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception ex)
                {
                    string message = ex.Message;
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }