예제 #1
0
    protected void lbtnAddToFavorite_Click(object sender, EventArgs e)
    {
        try
        {
            AddToFavorite objFavorite = new AddToFavorite();
            int returnVal = 0;
            objFavorite.UserId = _userId;
            objFavorite.TributeId = _tributeId;
            if (isInFavorite > 0)
            {
                objFavorite.ModifiedBy = _userId;
                objFavorite.ModifiedDate = DateTime.Now;
                objFavorite.EmailAlert = chkFavoritesEmailNotifications.Checked;
                objFavorite.IsActive = true;
                objFavorite.IsDeleted = true;
            }
            else
            {
                objFavorite.CreatedBy = _userId;
                objFavorite.CreatedDate = DateTime.Now;
                objFavorite.EmailAlert = chkFavoritesEmailNotifications.Checked;
                objFavorite.IsActive = true;
                objFavorite.IsDeleted = false;
            }

            MiscellaneousController _controller = new MiscellaneousController();
            if (isInFavorite > 0)
                _controller.RemoveFromFavotire(objFavorite);
            else
                returnVal = _controller.AddToFavorites(objFavorite);

            if (returnVal > 0) //already in favorite list
            {
                lblErrMsg.InnerHtml = ShowErrorMessage(ConfigurationManager.AppSettings["ApplicationType"].ToString().ToLower() == "yourmoments" ? ResourceText.GetString("errFavorite_Master1") : ResourceText.GetString("errFavorite_Master"));
                lblErrMsg.Visible = true;
            }
            else
            {
                lblErrMsg.Visible = false;
            }
            CheckForFavorite();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }