Exemplo n.º 1
0
        public ActionResult Save(SE_MDBeautyCategoryProductConfigModel model)
        {
            bool result = false;

            if (model != null)
            {
                try
                {
                    model.Brands = string.IsNullOrWhiteSpace(model.Brands) ? null : model.Brands;
                    if (model.PId == 0)
                    {
                        var userName = HttpContext.User?.Identity?.Name;
                        var data     = SyncProdcutLibrary(model, userName);
                        logger.Info(data);
                        result = SE_MDBeautyCategoryProductConfigBLL.BatchInsertOrUpdateSyncProdcutLibrary(data, model);
                    }
                    else
                    {
                        result = SE_MDBeautyCategoryProductConfigBLL.Update(model);
                        using (var client = new Tuhu.Service.Shop.CacheClient())
                        {
                            client.UpdateBeautyProductDetailByPid(model.PId);
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message, ex);
                }
            }
            return(RedirectToAction("Index", "SE_MDBeautyCategoryConfig"));
        }
Exemplo n.º 2
0
        public ActionResult Save(SE_MDBeautyCategoryProductConfigModel model)
        {
            bool result = false;

            if (model != null)
            {
                try
                {
                    var userName = HttpContext.User?.Identity?.Name;
                    model.Brands = string.IsNullOrWhiteSpace(model.Brands) ? null : model.Brands;
                    if (model.PId == 0)
                    {
                        var data = SyncProdcutLibrary(model, userName);
                        logger.Info(data);
                        result = SE_MDBeautyCategoryProductConfigBLL.BatchInsertOrUpdateSyncProdcutLibrary(data, model);
                    }
                    else
                    {
                        result          = SE_MDBeautyCategoryProductConfigBLL.Update(model);
                        model.ProdcutId = (SE_MDBeautyCategoryProductConfigBLL.Select(model.PId))?.ProdcutId;
                        var propinfo = new Dictionary <string, object>()
                        {
                            ["Image_filename"] = model.Image_filename
                        };
                        var updateResult = ProductService.UpdateProductByPropertyNames(model.ProdcutId, propinfo, userName);
                        if (!updateResult)
                        {
                            logger.Error($"更新产品图片属性失败,product:{JsonConvert.SerializeObject(model)}");
                        }
                        using (var client = new Tuhu.Service.Shop.CacheClient())
                        {
                            client.UpdateBeautyProductDetailByPid(model.PId);
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message, ex);
                }
            }
            return(RedirectToAction("Index", "SE_MDBeautyCategoryConfig"));
        }