Пример #1
0
 public ActionResult AjaxAddComment(FormCollection Fm)
 {
     if (string.IsNullOrWhiteSpace(Fm["ProductId"]))
     {
         return base.Content("False");
     }
     int num = Globals.SafeInt(Fm["ProductId"], 0);
     string productName = Fm["ProductName"];
     string str2 = InjectionFilter.SqlFilter(Fm["Content"]);
     Maticsoft.BLL.Shop.Products.ProductReviews reviews = new Maticsoft.BLL.Shop.Products.ProductReviews();
     Maticsoft.Model.Shop.Products.ProductReviews model = new Maticsoft.Model.Shop.Products.ProductReviews {
         CreatedDate = DateTime.Now,
         Status = 0,
         UserId = base.CurrentUser.UserID,
         UserName = base.CurrentUser.NickName,
         UserEmail = base.CurrentUser.Email,
         ParentId = 0,
         ProductId = num,
         ReviewText = str2
     };
     bool boolValueByCache = ConfigSystem.GetBoolValueByCache("Shop_Create_Post");
     if (!reviews.AddEx(model, productName, boolValueByCache))
     {
         return base.Content("False");
     }
     return base.Content("True");
 }
Пример #2
0
 public Maticsoft.Model.Shop.Products.ProductReviews DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Shop.Products.ProductReviews reviews = new Maticsoft.Model.Shop.Products.ProductReviews();
     if (row != null)
     {
         if ((row["ReviewId"] != null) && (row["ReviewId"].ToString() != ""))
         {
             reviews.ReviewId = int.Parse(row["ReviewId"].ToString());
         }
         if ((row["ProductId"] != null) && (row["ProductId"].ToString() != ""))
         {
             reviews.ProductId = long.Parse(row["ProductId"].ToString());
         }
         if ((row["UserId"] != null) && (row["UserId"].ToString() != ""))
         {
             reviews.UserId = int.Parse(row["UserId"].ToString());
         }
         if (row["ReviewText"] != null)
         {
             reviews.ReviewText = row["ReviewText"].ToString();
         }
         if (row["UserName"] != null)
         {
             reviews.UserName = row["UserName"].ToString();
         }
         if (row["UserEmail"] != null)
         {
             reviews.UserEmail = row["UserEmail"].ToString();
         }
         if ((row["CreatedDate"] != null) && (row["CreatedDate"].ToString() != ""))
         {
             reviews.CreatedDate = DateTime.Parse(row["CreatedDate"].ToString());
         }
         if ((row["ParentId"] != null) && (row["ParentId"].ToString() != ""))
         {
             reviews.ParentId = int.Parse(row["ParentId"].ToString());
         }
         if ((row["Status"] != null) && (row["Status"].ToString() != ""))
         {
             reviews.Status = int.Parse(row["Status"].ToString());
         }
         if ((row["OrderId"] != null) && (row["OrderId"].ToString() != ""))
         {
             reviews.OrderId = long.Parse(row["OrderId"].ToString());
         }
         if (row["SKU"] != null)
         {
             reviews.SKU = row["SKU"].ToString();
         }
         if (row["Attribute"] != null)
         {
             reviews.Attribute = row["Attribute"].ToString();
         }
         if (row["ImagesPath"] != null)
         {
             reviews.ImagesPath = row["ImagesPath"].ToString();
         }
         if (row["ImagesNames"] != null)
         {
             reviews.ImagesNames = row["ImagesNames"].ToString();
         }
     }
     return reviews;
 }
Пример #3
0
 public ActionResult AjAxPReview(FormCollection fm)
 {
     string str = fm["PReviewjson"];
     if (!string.IsNullOrWhiteSpace(str))
     {
         int num4;
         Maticsoft.BLL.Shop.Products.ProductReviews reviews = new Maticsoft.BLL.Shop.Products.ProductReviews();
         List<Maticsoft.Model.Shop.Products.ProductReviews> modelList = new List<Maticsoft.Model.Shop.Products.ProductReviews>();
         JsonArray array = JsonConvert.Import<JsonArray>(str);
         long orderId = -1L;
         foreach (JsonObject obj2 in array)
         {
             long num2 = Globals.SafeInt(obj2["pid"].ToString(), -1);
             orderId = Globals.SafeInt(obj2["orderId"].ToString(), -1);
             string str2 = InjectionFilter.Filter(obj2["contentval"].ToString());
             string str3 = Globals.SafeString(obj2["imagesurlPath"].ToString(), "");
             string str4 = Globals.SafeString(obj2["imagesurlName"].ToString(), "");
             string str5 = InjectionFilter.Filter(obj2["attribute"].ToString());
             string str6 = InjectionFilter.Filter(obj2["sku"].ToString());
             if (((num2 <= 0L) || (orderId <= 0L)) || string.IsNullOrWhiteSpace(str2))
             {
                 return base.Content("false");
             }
             Maticsoft.Model.Shop.Products.ProductReviews item = new Maticsoft.Model.Shop.Products.ProductReviews {
                 Attribute = str5,
                 CreatedDate = DateTime.Now,
                 OrderId = orderId,
                 ProductId = num2,
                 ReviewText = str2,
                 SKU = str6,
                 Status = 0,
                 UserEmail = base.currentUser.Email,
                 UserId = base.currentUser.UserID,
                 UserName = base.currentUser.UserName,
                 ParentId = 0
             };
             if (!string.IsNullOrWhiteSpace(str3) && !string.IsNullOrWhiteSpace(str4))
             {
                 string virtualPath = string.Format("/Upload/Shop/ProductReviews/{0}/", DateTime.Now.ToString("yyyyMM"));
                 string path = base.Request.MapPath(virtualPath);
                 if (!Directory.Exists(path))
                 {
                     Directory.CreateDirectory(path);
                 }
                 string[] strArray = str3.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                 string[] strArray2 = str4.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                 if (strArray.Length != strArray2.Length)
                 {
                     throw new ArgumentOutOfRangeException("路径与文件名长度不匹配!");
                 }
                 for (int i = 0; i < strArray.Length; i++)
                 {
                     File.Move(base.Request.MapPath(strArray[i]), path + strArray2[i]);
                 }
                 item.ImagesPath = virtualPath + "{0}";
                 item.ImagesNames = string.Join("|", strArray2);
             }
             modelList.Add(item);
         }
         if ((modelList.Count > 0) && reviews.AddEx(modelList, orderId, out num4))
         {
             return base.Content(num4.ToString());
         }
     }
     return base.Content("false");
 }