public static bool Update(SE_GiftManageConfigModel model) { try { var giftFlag = true; var reGiftP = SE_GiftManageConfigDAL.DeleteGiftProductConfig(model.Id); giftFlag = giftFlag && reGiftP >= 0; var giftProductModels = JsonConvert.DeserializeObject <List <GiftStockModel2> >(model.GiftProducts); foreach (var g in giftProductModels) { g.RuleId = model.Id; giftFlag = giftFlag && SE_GiftManageConfigDAL.MergeIntoGiftProductStock(g.Pid, g.Stock, model.Id) > 0; giftFlag = giftFlag && SE_GiftManageConfigDAL.InsertGiftProductConfig(g) > 0; } var result = SE_GiftManageConfigDAL.Update(ProcessConnection.OpenConfiguration, model) && giftFlag; // 按PID配置赠品后刷新牛皮癣缓存 RefreshGiftPicture(model); return(result); } catch (Exception ex) { throw ex; } }
public static bool Insert(SE_GiftManageConfigModel model, SE_DictionaryConfigModel log) { try { var result = SE_GiftManageConfigDAL.Insert(ProcessConnection.OpenConfiguration, model); var giftFlag = true; log.ParentId = result; //var reGiftP = SE_GiftManageConfigDAL.DeleteGiftProductConfig(result); var giftProductModels = JsonConvert.DeserializeObject <List <GiftStockModel2> >(model.GiftProducts); foreach (var g in giftProductModels) { g.RuleId = result; g.IsGiveAway = model.GiveAway; giftFlag = giftFlag && SE_GiftManageConfigDAL.MergeIntoGiftProductStock(g.Pid, g.Stock, result) > 0; giftFlag = giftFlag && SE_GiftManageConfigDAL.InsertGiftProductConfig(g) > 0; } // 按PID配置赠品后刷新牛皮癣缓存 RefreshGiftPicture(model); return(result > 0 && SE_GiftManageConfigDAL.InsertLog(ProcessConnection.OpenConfiguration, log) && giftFlag); } catch (Exception ex) { throw ex; } }