public static int UpdateFavorite(int favoriteId, string tags, string remark) { FavoriteDao favoriteDao = new FavoriteDao(); string text = ""; string[] array = null; array = ((!tags.Contains(",")) ? new string[1] { tags } : tags.Split(',')); string[] array2 = array; foreach (string text2 in array2) { if (!string.IsNullOrEmpty(DataHelper.CleanSearchString(text2.Trim()))) { favoriteDao.UpdateOrAddFavoriteTags(text2.Trim(), HiContext.Current.UserId); string text3 = tags.Replace(text2, ""); int num = (tags.Length - text3.Length) / text2.Length; if (num == 1 || !text.Contains(text2)) { text = text + DataHelper.CleanSearchString(text2) + ","; } } } if (!string.IsNullOrEmpty(text)) { text = text.Substring(0, text.Length - 1); } return(new FavoriteDao().UpdateFavorite(favoriteId, tags, remark)); }
public InsertNewFavoriteResult InsertNewFavorite(int userId, int storyId) { var maybeStory = Context.Stories.SingleOrDefault(s => s.Id == storyId); if (maybeStory == null) { return InsertNewFavoriteResult.StoryDoesNotExist; } var maybeUser = Context.Users.Single(u => u.Id == userId); if (maybeUser == null) { return InsertNewFavoriteResult.UserDoesNotExist; } var alreadyExists = Context.Favorites.Any(f => f.User.Id == userId && f.StoryDao.Id == storyId); if (alreadyExists) { return InsertNewFavoriteResult.IsAlreadyFavorite; } var dao = new FavoriteDao { StoryDao = maybeStory, User = maybeUser }; Context.Favorites.Add(dao); Context.SaveChanges(); return InsertNewFavoriteResult.Success; }
public static string GetFavoriteTags() { string text = string.Empty; DataSet favoriteTags = new FavoriteDao().GetFavoriteTags(); if (favoriteTags.Tables.Count > 0) { foreach (DataRow dataRow in favoriteTags.Tables[0].Rows) { object obj = text; text = string.Concat(new object[] { obj, "{\"TagId\":\"", dataRow["TagId"], "\",\"TagName\":\"", dataRow["TagName"], "\"}," }); } } if (text.Length > 1) { text = text.Substring(0, text.Length - 1); } return(text); }
public static int AddProductToFavorite(int productId, int userId, int storeId = 0) { FavoriteDao favoriteDao = new FavoriteDao(); if (favoriteDao.ExistsProduct(productId, userId, storeId)) { return((favoriteDao.DeleteFavorite(userId, productId, storeId) > 0) ? 1 : 0); } return((ProductBrowser.AddProduct(productId, userId, storeId) > 0) ? 2 : 0); }
public static int AddProduct(int productId, int userId, int storeId = 0) { FavoriteDao favoriteDao = new FavoriteDao(); if (favoriteDao.ExistsProduct(productId, userId, storeId)) { return(1); } FavoriteInfo model = new FavoriteInfo { ProductId = productId, UserId = userId, StoreId = storeId, Tags = "" }; return((int)favoriteDao.Add(model, null)); }
public static int UpdateFavorite(int favoriteId, string tags, string remark) { FavoriteDao favoriteDao = new FavoriteDao(); string text = ""; string[] array; if (tags.Contains(",")) { array = tags.Split(new char[] { ',' }); } else { array = new string[] { tags }; } string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text2 = array2[i]; if (!string.IsNullOrEmpty(DataHelper.CleanSearchString(text2.Trim()))) { favoriteDao.UpdateOrAddFavoriteTags(text2.Trim()); string text3 = tags.Replace(text2, ""); int num = (tags.Length - text3.Length) / text2.Length; if (num == 1 || !text.Contains(text2)) { text = text + DataHelper.CleanSearchString(text2) + ","; } } } if (!string.IsNullOrEmpty(text)) { text = text.Substring(0, text.Length - 1); } return(new FavoriteDao().UpdateFavorite(favoriteId, tags, remark)); }
public static string GetFavoriteTags() { if (HiContext.Current.UserId == 0) { return(string.Empty); } string text = string.Empty; DataSet favoriteTags = new FavoriteDao().GetFavoriteTags(HiContext.Current.UserId); if (favoriteTags.Tables.Count > 0) { foreach (DataRow row in favoriteTags.Tables[0].Rows) { text = text + "{\"TagId\":\"" + row["TagId"] + "\",\"TagName\":\"" + row["TagName"] + "\"},"; } } if (text.Length > 1) { text = text.Substring(0, text.Length - 1); } return(text); }
public static bool AddProductToFavorite(int productId, int userId) { FavoriteDao dao = new FavoriteDao(); return(dao.ExistsProduct(productId, userId) || dao.AddProductToFavorite(productId, userId)); }
public static DataTable GetFavoritesTypeTags() { FavoriteDao favoriteDao = new FavoriteDao(); return(favoriteDao.GetTypeTags(HiContext.Current.UserId)); }
public FavoriteService(FavoriteDao favoriteDao) { _favoriteDao = favoriteDao; }
public static bool AddProductToFavorite(int productId, int userId) { FavoriteDao dao = new FavoriteDao(); return (dao.ExistsProduct(productId, userId) || dao.AddProductToFavorite(productId, userId)); }
public static DataTable GetFavoritesTypeTags() { FavoriteDao favoriteDao = new FavoriteDao(); return(favoriteDao.GetTypeTags()); }
public static int AddProduct(int productId, int userId) { FavoriteDao favoriteDao = new FavoriteDao(); return(favoriteDao.AddProduct(productId, userId)); }
public static bool CollectProduct(int productId, int userId, string tags, string remark) { FavoriteDao favoriteDao = new FavoriteDao(); return(favoriteDao.AddProductToFavorite(productId, userId, tags, remark)); }