public string AddUserFavoritePage(string userId, string pageName, string ctrl) { string crlHash = Generic.GetHash(Generic.GetWebConfigValue("WebServiceKey")); //if (ctrl != crlHash) return js.Serialize(""); db_config_users dcu = null; try { // first validation to guarantee that user is greater than zero int auxUserId = Convert.ToInt32(userId); if (auxUserId < 0) return string.Empty; dcu = new db_config_users(auxUserId); dcu.Open(); Users u = dcu.Get(auxUserId); if (u == null) return string.Empty; // if user does not exists will leave width no return message OptionItems oi = new OptionItems(u.UserOptions); List<string> favoriteList = oi.GetList("favorites"); if (favoriteList.IndexOf(pageName) < 0) { favoriteList.Add(pageName); oi.UpdateOptions("favorites", favoriteList); u.UserOptions = oi.GetOptionsString(); dcu.Commit(); return "page added to favorites"; } else return "page already added to favorite."; } catch (Exception ex) { loging.Error("FrontOffice User Webservice", "Add User Favorite Page", ex.Message, _logRecord); } finally { if (dcu != null) dcu.Close(); } return "failed to add page"; }
public string SetUserDefaultFrontOfficePage(string userId, string pageName, string ctrl) { string crlHash = Generic.GetHash(Generic.GetWebConfigValue("WebServiceKey")); //if (ctrl != crlHash) return js.Serialize(""); db_config_users dcu = null; try { // first validation to guarantee that user is greater than zero int auxUserId = Convert.ToInt32(userId); if (auxUserId < 0) return string.Empty; dcu = new db_config_users(auxUserId); dcu.Open(); Users u = dcu.Get(auxUserId); if (u == null) return string.Empty; // if user does not exists it will leave with no return messsage OptionItems oi = new OptionItems(u.UserOptions); oi.UpdateOptions("default_frontoffice_page", new List<string> { pageName }); u.UserOptions = oi.GetOptionsString(); dcu.Commit(); return pageName != "" ? "Page " + pageName + " is set as default frontoffice page" : "Default frontoffice page is clean"; } catch (Exception ex) { loging.Error("FrontOffice User Webservice", "Add User Favorite Page", ex.Message, _logRecord); } finally { if (dcu != null) dcu.Close(); } return "failed to set page"; }