|
// VideoLibrary DEMO - DaST Technology Demonstrator
// Copyright (C) 2011 Roman Gubarenko
// http://www.rgubarenko.net
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// Licence terms for AspNetDaST.dll (in Bin folder) are below.
//
// ASP.NET DaST Rendering Engine (BETA version)
// Copyright (C) 2011 Roman Gubarenko
// http://www.rgubarenko.net
//
// Redistribution and use of BETA version of DaST Rendering Engine
// is permitted in binary form without modification. Only original and
// unmodified .NET dll (AspNetDaST.dll) can be used in your own projects and
// redistributed. You may not copy, decompile, reverse engineer, disassemble,
// modify, or create derivative works of the software or any part thereof.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE.
//
// DaST technology dev site: http://www.rgubarenko.net
// My contact email for questions: rgubarenko@gmail.com
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AspNetDaST.Web;
/// <summary>
/// Summary description for VideoItemController
/// </summary>
public class VideoItemController : ScopeController
{
public override void SetTemplate(SetTemplateArgs template)
{
template.Markup = Utils.LoadTemplate("VideoItemTemplate.htm");
}
public override void SetupModel(ControllerModelBuilder model)
{
model.SetDataBind(new DataBindHandler(ROOT_DataBind));
model.HandleAction("AddToPlaylist", new ActionHandler(Action_AddToPlaylist));
model.HandleAction("RemoveFromPlaylist", new ActionHandler(Action_RemoveFromPlaylist));
}
private void Action_AddToPlaylist(ActionArgs args)
{
string videoID = (string)args.ActionData;
DataLayer.AddToPlaylist(videoID);
ControlPath.Scope.Refresh();
RaiseAction("PlaylistUpdated", null);
}
private void Action_RemoveFromPlaylist(ActionArgs args)
{
string videoID = (string)args.ActionData;
DataLayer.RemoveFromPlaylist(videoID);
ControlPath.Scope.Refresh();
RaiseAction("PlaylistUpdated", null);
}
private void ROOT_DataBind()
{
var itemInfo = ControlPath.Scope.Param<Dictionary<string, object>>("VideoItemObject");
CurrentPath.Scope.Replace("{ID}", itemInfo["ID"]);
CurrentPath.Scope.Replace("{Name}", itemInfo["Name"]);
CurrentPath.Scope.Replace("{Category}", itemInfo["Category"]);
CurrentPath.Scope.Replace("{Description}", itemInfo["Description"]);
CurrentPath.Scope.Replace("{Rating}", Convert.ToDecimal(itemInfo["Rating"]).ToString("0.0"));
CurrentPath.Scope.Replace("{CommCount}", itemInfo["CommCount"]);
CurrentPath.Fwd("AddButton").Scope.Replace("{ID}", itemInfo["ID"]);
CurrentPath.Fwd("RemoveButton").Scope.Replace("{ID}", itemInfo["ID"]);
if (DataLayer.CheckPlaylistContains((string)itemInfo["ID"]))
{
CurrentPath.Fwd("AddButton").Scope.RenderType = ScopeRenderType.None;
CurrentPath.Fwd("RemoveButton").Scope.RenderType = ScopeRenderType.Normal;
}
else
{
CurrentPath.Fwd("AddButton").Scope.RenderType = ScopeRenderType.Normal;
CurrentPath.Fwd("RemoveButton").Scope.RenderType = ScopeRenderType.None;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Software Architect with over 15 years in IT field. Started with deep math and C++ Computer Vision software. Currently in .NET and PHP web development. Creator of DaST pattern, open-source frameworks, and plugins. Interested in cutting Edge IT, open-source, Web 2.0, .NET, MVC, C++, Java, jQuery, Mobile tech, and extreme sports.