[Back]

// DotNetNukeŽ - http://www.dotnetnuke.com
// Copyright (c) 2002-2009
// by DotNetNuke Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
//

using System;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke.Common;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Entities.Users;

namespace DotNetNuke.Modules.DNNSilverlightChat
{
    public partial class Edit : DotNetNuke.Entities.Modules.PortalModuleBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if ((Page.IsPostBack == false))
                {

                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }

        #region lnkBack_Click
        protected void lnkBack_Click(object sender, EventArgs e)
        {
            Response.Redirect(Globals.NavigateURL(), true);
        }
        #endregion

        #region LDSChatLog_Selecting
        protected void LDSChatLog_Selecting(object sender, LinqDataSourceSelectEventArgs e)
        {
            e.WhereParameters["ModuleId"] = ModuleId;
        }
        #endregion

        #region ListView1_ItemDataBound
        protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            Label UserIDLabel = (Label)e.Item.FindControl("UserIDLabel");
            if (UserIDLabel != null)
            {
                UserIDLabel.Text = UserController.GetUser(PortalId, Convert.ToInt32(UserIDLabel.Text), false).DisplayName;
            }
        }
        #endregion

        #region lnkDelete_Click
        protected void lnkDelete_Click(object sender, EventArgs e)
        {
            DNNSilverlightChatDALDataContext objDNNSilverlightChatDALDataContext = new DNNSilverlightChatDALDataContext();

            var results = from DNNSilverlightChat_Messages in objDNNSilverlightChatDALDataContext.DNNSilverlightChat_Messages
                          where DNNSilverlightChat_Messages.ModuleID == ModuleId
                          select DNNSilverlightChat_Messages;

            objDNNSilverlightChatDALDataContext.DNNSilverlightChat_Messages.DeleteAllOnSubmit(results);
            objDNNSilverlightChatDALDataContext.SubmitChanges();

            lvMessages.DataBind();
        }
        #endregion
    }
}