Search

just show me the code

Wednesday, November 26, 2008

My Dependency Injection


ITalentRepository.cs

    9     public interface ITalentRepository
   10     { 
   11         IQueryable<Talent> GetTalents(); 
   12         void SaveTalent(Talent talent);  
   13     }


TestTalentRepository.cs

   11     public class TestTalentRepository : ITalentRepository
   12     {
   13         IList<Talent> talentList;
   14         IList<TalentEvent> talentEventList;
   15
   16         public TestTalentRepository(IResponseRepository _responseRepository, IEventRepository _eventRepository)
   17         { 
   18             //load up the repo list
   19             talentList = new List<Talent>();
   20             talentEventList = new List<TalentEvent>();
   21
   22             for (int i = 0; i < 55; i++)
   23             {
   24                 var t = new Talent();
   25                 t.Id = i;
   26                 t.FirstName = (i % 4 == 1) ? "Quin" : (i % 4 == 2) ? "George" : (i % 4 == 3) ? "Ryan" : "Joe";
   27                 t.LastName = (i%3 == 1) ? "Simpson" + i.ToString() : "Zimmerman";
   28                 if (i == 24) t.LastName = "Anderson";
   29                 if (i == 23) t.LastName = "Beckman";
   30                 if (i == 22) t.LastName = "Chambers";
   31                 if (i == 21) t.LastName = "Ewalt";
   32                 if (i == 20) t.LastName = "Davis" + i.ToString();
   33                 if (i == 19) t.LastName = "Ferg" + i.ToString();
   34                 if (i == 18) t.LastName = "Gainer" + i.ToString();
   35                 if (i == 1) t.LastName = "Anderson";
   36                 if (i == 2) t.LastName = "Beckman";
   37                 if (i == 3) t.LastName = "Chambers";
   38                 if (i == 4) t.LastName = "Ewalt";
   39                 if (i == 5) t.LastName = "Davis" + i.ToString();
   40                 if (i == 6) t.LastName = "Ferg" + i.ToString();
   41                 if (i == 7) t.LastName = "Gainer" + i.ToString();
   42                 if (i % 13 == 4) {t.FirstName = string.Empty; t.LastName = string.Empty;}
   43                 t.EyeColor = (i%5 == 0) ? EyeColor.Brown : (i%6 == 0) ? EyeColor.Unknown : EyeColor.Black;
   44
   45                 int x =
   46                     (int)
   47                     Enum.Parse(typeof (TalentStatusEnum),
   48                                Enum.GetName(typeof (TalentStatusEnum), TalentStatusEnum.Approved));
   49
   50                 t.TalentStatusID = x;
   51                 t.TalentStatus = TalentStatusEnum.Approved;
   52                 t.TalentStatus = (i%5 == 0) ? TalentStatusEnum.DoNotUse : 
   53                     (i%6 == 0) ? TalentStatusEnum.New : TalentStatusEnum.Approved;
   54
   55
   56                 t.City = (i%5 == 0) ? "Miami" : (i%6 == 0) ? "Tampa" : "Chicago";
   57                 t.State = (i % 5 == 0) ? "FL" : (i % 6 == 0) ? "FL" : "IL";
   58                 t.Company = (i % 7 == 1) ? "Argo Talent Agency" :
   59                     (i % 7 == 2) ? "Simpson & Argo & Talent Event Repository Talent Solutions" : 
   60                     (i % 7 == 3) ? string.Empty : "Smith Sound & DJ Solutions";
   61
   62                 //t.DateOfBirth = (i % 5 == new DateTime("1/1/")) ? 23 : (i % 5 == 2) ? 32 : (i % 5 == 3) ? 26 : 36;
   63                 t.Age = (i % 5 == 1) ? 23 : (i % 5 == 2) ? 32 : (i % 5 == 3) ? 26 : 36;
   64                 t.Gender = (i % 7 == 0) ? "" : (i % 3 == 1) ? "Female" : "Male";
   65                 t.Race = (i % 5 == 1) ? "Asian" :
   66                     (i % 5 == 2) ? "African-American" :
   67                     (i % 5 == 3) ? "Hispanic" : "Caucasian";
   68
   69                 t.Email = (i % 5 == 1) ?  t.FirstName + "_" + t.LastName + i.ToString() + "@aol.com" :
   70                     (i % 5 == 2) ? t.FirstName + "_" + t.LastName + i.ToString() + "@hotmail.com" :
   71                     (i % 5 == 3) ? "j" + i.ToString() + "@gmail.com" : t.LastName + i.ToString() + "@yahoo.com";
   72
   73                 t.FileNumber = (1000 + i).ToString();
   74
   75                 //t.TalentTypes = new LazyList<TalentTypeTalent>();
   76                 //int qid = Convert.ToInt32(QuestionEnum.t
   77                 //_responseRepository.GetResponses().Where(x => x.Questions.Any(q => q.QuestionID == qid));
   78
   79                 IList<Event> events = _eventRepository.GetEvents().ToList<Event>();
   80                 Random random = new Random();   
   81                 int numEvents = random.Next(events.Count);
   82                 t.TalentEvents = new LazyList<TalentEvent>();
   83                 for (int j= 0; j < numEvents; j++)
   84                 {
   85                     var te = new TalentEvent();
   86                     te.TalentEventID = j;
   87                     te.TalentID = i;
   88                     //var e = events.GetEvents().FirstOrDefault();
   89                     Random random2 = new Random();
   90                     int rand = random2.Next(events.Count);
   91                     var e = events.ElementAtOrDefault(rand);
   92                     events.RemoveAt(rand);
   93                     te.Event = e;
   94                     te.EventID = e.EventID;
   95                     t.TalentEvents.Add(te);
   96                     t.Events += e.EventName + ", ";
   97                 }
   98                 talentList.Add(t);
   99             }
  100         }
  101
  102
  103
  104         public IQueryable<Talent> GetTalents()
  105         {
  106             return talentList.AsQueryable<Talent>();
  107         }
  108
  109         public void SaveTalent(Talent talent)
  110         {
  111             if (talent.Id > 0)
  112             {
  113                 Talent t = talentList.Where(x => x.Id == talent.Id).SingleOrDefault();
  114                 if (t != null)
  115                 {
  116                     talentList.Remove(t);
  117                     talentList.Add(talent);
  118                 }
  119                 else
  120                 {
  121                     talentList.Add(talent);
  122                 }
  123             }
  124             else
  125             {
  126                 int maxId = this.talentList.Max(t => t.Id);
  127                 talent.Id = maxId + 1;
  128
  129                 this.talentList.Add(talent);
  130             }
  131         }  
  132     }



ITalentService.cs

   11     public interface ITalentService
   12     {
   13         IQueryable<Talent> GetTalents(string searchExpression);
   14         IQueryable<Talent> GetTalents();
   15
   16         PagedList<Talent> GetPagedTalents(string searchExpression, string sortExpression, int pageIndex, int pageSize);
   17
   18         void SaveTalent(Talent t);
   19
   20     }


TalentService.cs

   13     public class TalentService : ITalentService
   14     { 
   15         ITalentRepository _repository = null;
   16
   17
   18         public TalentService(ITalentRepository repository) 
   19         {
   20             _repository = repository; 
   21             if (_repository == null)
   22                 throw new InvalidOperationException("Repository cannot be null");
   23         }
   24
   25
   26         public PagedList<Talent> GetPagedTalents(string searchExpression, string sortExpression, int pageIndex, int pageSize)
   27         {
   28             var qt = this.GetTalents(searchExpression);
   29             return GetPagedTalents(qt, sortExpression, pageIndex, pageSize);
   30         }
   31
   32
   33         public PagedList<Talent> GetPagedTalents(IQueryable<Talent> qt , string sortExpression, int pageIndex, int pageSize)
   34         {
   35             PagedList<Talent> tList; 
   36             switch (sortExpression.Split(' ')[0])
   37             {
   38                 case "Id":
   39                     tList = new PagedList<Talent>(qt.OrderBy(tal => tal.Id), pageIndex, pageSize);
   40                     break;
   41                 case "LastName":
   42                     tList = new PagedList<Talent>(qt.OrderBy(tal => tal.LastName)
   43                         .ThenBy(tal => tal.FirstName)
   44                         .ThenBy(tal => tal.Id), pageIndex, pageSize);
   45                     break;
   46                 case "FirstName":
   47                     tList = new PagedList<Talent>(qt.OrderBy(tal => tal.FirstName)
   48                         .ThenBy(tal => tal.LastName)
   49                         .ThenBy(tal => tal.Id), pageIndex, pageSize);
   50                     break;
   51                 case "Eye":
   52                     tList = new PagedList<Talent>(qt.OrderBy(tal => tal.EyeColor.ToString())
   53                         .ThenBy(tal => tal.LastName)
   54                         .ThenBy(tal => tal.FirstName)
   55                         .ThenBy(tal => tal.Id), pageIndex, pageSize);
   56                     break;
   57                 case "TalentStatus":
   58                     tList = new PagedList<Talent>(qt.OrderBy(tal => tal.TalentStatus.ToString())
   59                         .ThenBy(tal => tal.LastName)
   60                         .ThenBy(tal => tal.FirstName)
   61                         .ThenBy(tal => tal.Id), pageIndex, pageSize);
   62                     break;
   63                 case "City":
   64                     tList = new PagedList<Talent>(qt.OrderBy(tal => tal.City.ToString())
   65                         .ThenBy(tal => tal.LastName)
   66                         .ThenBy(tal => tal.FirstName)
   67                         .ThenBy(tal => tal.Id), pageIndex, pageSize);
   68                     break;
   69                 case "State":
   70                     tList = new PagedList<Talent>(qt.OrderBy(tal => tal.State.ToString())
   71                         .ThenBy(tal => tal.LastName)
   72                         .ThenBy(tal => tal.FirstName)
   73                         .ThenBy(tal => tal.Id), pageIndex, pageSize);
   74                     break;
   75                 case "Gender":
   76                     tList = new PagedList<Talent>(qt.OrderBy(tal => tal.Gender.ToString())
   77                         .ThenBy(tal => tal.LastName)
   78                         .ThenBy(tal => tal.FirstName)
   79                         .ThenBy(tal => tal.Id), pageIndex, pageSize);
   80                     break;
   81                 case "Company":
   82                     tList = new PagedList<Talent>(qt.OrderBy(tal => tal.Company.ToString())
   83                         .ThenBy(tal => tal.LastName)
   84                         .ThenBy(tal => tal.FirstName)
   85                         .ThenBy(tal => tal.Id), pageIndex, pageSize);
   86                     break;
   87                 case "Race":
   88                     tList = new PagedList<Talent>(qt.OrderBy(tal => tal.Race.ToString())
   89                         .ThenBy(tal => tal.LastName)
   90                         .ThenBy(tal => tal.FirstName)
   91                         .ThenBy(tal => tal.Id), pageIndex, pageSize);
   92                     break;
   93                 case "Age":
   94                     tList = new PagedList<Talent>(qt.OrderBy(tal => tal.Age.ToString())
   95                         .ThenBy(tal => tal.LastName)
   96                         .ThenBy(tal => tal.FirstName)
   97                         .ThenBy(tal => tal.Id), pageIndex, pageSize);
   98                     break;
   99                 default:
  100                     tList = new PagedList<Talent>(qt.OrderBy(tal => tal.Id), pageIndex, pageSize); 
  101                     break;
  102             }
  103             return tList; 
  104         }
  105
  106
  107         public IQueryable<Talent> GetTalents()
  108         {
  109             return this.GetTalents(null);
  110         }
  111
  112         public IQueryable<Talent> GetTalents(string searchExpression)
  113         {
  114             IQueryable<Talent> t;
  115             if (string.IsNullOrEmpty(searchExpression))
  116             {
  117                 t = _repository.GetTalents();
  118             }
  119             else if (SearchStringUtil.IsAdvSearch(searchExpression))
  120             {
  121                 t = AdvSearch(searchExpression);
  122             }
  123             else  
  124             {
  125                 t = BasicSearch(searchExpression);
  126             }
  127             return t;
  128         }
  129
  130         private IQueryable<Talent> AdvSearch(string searchExpression)
  131         {
  132             IQueryable<Talent> t;
  133             string[] sa = searchExpression.Trim().Replace("  ", " ").Replace("  ", " ").Split(' ');
  134             t = _repository.GetTalents();
  135             foreach (string s in sa)
  136             {
  137                 t = t.Intersect(AddAdvSearch(s));
  138             }
  139             return t;
  140         }
  141
  142         private IQueryable<Talent> AddAdvSearch(string s)
  143         {
  144             string[] sa = s.Split(':');
  145             var t2 =  _repository.GetTalents();
  146             if (sa.Length == 2)
  147             {
  148                 sa[1] = sa[1].ToLower();
  149                 switch (sa[0])
  150                 {
  151                     case "FirstName":
  152                         {
  153                             t2 = _repository.GetTalents()
  154                                 .Where(tal => tal.FirstName.ToString().ToLower().Contains(sa[1]));
  155                             break;
  156                         }
  157                     case "LastName":
  158                         {
  159                             t2 = _repository.GetTalents()
  160                                 .Where(tal => tal.LastName.ToString().ToLower().Contains(sa[1]));
  161                             break;
  162                         }
  163                     case "Email":
  164                         {
  165                             t2 = _repository.GetTalents()
  166                                 .Where(tal => tal.Email.ToString().ToLower().Contains(sa[1]));
  167                             break;
  168                         }
  169                     case "TalentType":
  170                         {
  171                             break;
  172                         }
  173                     case "Event":
  174                         { 
  175                             t2 = _repository.GetTalents()
  176                                 .Where(tal => tal.TalentEvents
  177                                     .Any<TalentEvent>(x=>x.Event.EventName.ToLower().Contains(sa[1])));
  178                             break;
  179                         }
  180                     case "Race":
  181                         {
  182                             t2 = _repository.GetTalents()
  183                                 .Where(tal => tal.Race.ToString().ToLower().Contains(sa[1]));
  184                             break;
  185                         }
  186                     case "Gender":
  187                         {
  188                             break;
  189                         }
  190                     case "City":
  191                         {
  192                             t2 = _repository.GetTalents()
  193                                 .Where(tal => tal.City.ToString().ToLower().Contains(sa[1]));
  194                             break;
  195                         }
  196                     case "State":
  197                         {
  198                             break;
  199                         }
  200                     case "FileNumber":
  201                         {
  202                             t2 = _repository.GetTalents()
  203                                 .Where(tal => tal.FileNumber.ToString().ToLower().Contains(sa[1]));
  204                             break;
  205                             break;
  206                         }
  207                     default:
  208                         break;
  209                 }
  210             }
  211             return t2;
  212         }
  213
  214         private IQueryable<Talent> BasicSearch(string searchExpression)
  215         {
  216             IQueryable<Talent> t;
  217             string[] sa = searchExpression.Trim().ToLower().Replace("  ", " ").Replace("  ", " ").Split(' ');
  218             t = _repository.GetTalents();
  219             foreach (string s in sa)
  220             { 
  221                 t = t.Intersect(AddBasicSearch(s));
  222             }
  223             return t;
  224         }
  225
  226         private IQueryable<Talent> AddBasicSearch(string s)
  227         {
  228             IQueryable<Talent> t2 = _repository.GetTalents()
  229                 .Where(tal => tal.EyeColor.ToString().ToLower().Contains(s)
  230                               || tal.FirstName.ToLower().Contains(s)
  231                               || tal.LastName.ToLower().Contains(s)
  232                               || tal.City.ToLower().Contains(s)
  233                               || tal.State.ToLower().Contains(s) 
  234                               || tal.Company.ToLower().Contains(s)
  235                               || tal.Gender.ToLower().Contains(s)
  236                               || tal.Race.ToLower().Contains(s)
  237                               || tal.Email.ToLower().Contains(s)
  238                               || tal.FileNumber.ToLower().Contains(s)
  239                               //|| tal.TalentTypeTalents.Any<Tal
  240                               || tal.TalentEvents.Any<TalentEvent>(x=>x.Event.EventName.ToLower().Contains(s))
  241                               || tal.TalentStatus.ToString().ToLower().Contains(s)
  242                               || tal.Id.ToString().Contains(s));
  243             return t2;
  244         }
  245
  246         public void SaveTalent(Talent t)
  247         {
  248             _repository.SaveTalent(t);
  249         } 
  250     }



TestBase.cs

   21     [TestClass]
   22     public class TestBase
   23     {
   24         protected ITalentRepository _talentRepository;
   25         protected ITalentService _talentService;
   26         protected IEventRepository _eventRepository;
   27         protected IEventService _eventService;
   28         protected IResponseRepository _responseRepository;
   29         protected IResponseService _responseService;
   30         protected IAuthenticationService _authenticationService;
   31         protected IAuthorizationService _authorizationService;
   32
   33         [TestInitialize]
   34         public void Startup()
   35         {
   36             _eventRepository = new TestEventRepository();
   37             _eventService = new EventService(_eventRepository);
   38             _responseRepository = new TestResponseRepository();
   39             _responseService = new ResponseService(_responseRepository);
   40             _talentRepository = new TestTalentRepository(_responseRepository, _eventRepository);
   41             _talentService = new TalentService(_talentRepository);
   42             _authenticationService = new TestAuthenticationService();
   43             _authorizationService = new TestAuthorizationService(); 
   44         }
   45     }



TalentTest.cs

  176         [TestMethod]
  177         public void TalentServiceShouldInsertNewTalentOnSave()
  178         {
  179             Talent t = new Talent();
  180             t.Id = -2000;
  181             t.FirstName = "Walter";
  182             t.LastName = "Payton";
  183
  184             int talentCount = _talentService.GetTalents().Count();
  185             _talentService.SaveTalent(t);
  186             int talentCount2 = _talentService.GetTalents().Count();
  187             Assert.IsTrue(talentCount2 == talentCount + 1);
  188         }
  189
  190
  191         [TestMethod]
  192         public void TalentServiceShouldInsert_2_NewTalentsOnSave()
  193         {
  194             const int newId = -1;
  195             Talent t = new Talent();
  196             t.Id = newId;
  197             t.FirstName = "Walter";
  198             t.LastName = "Payton";
  199
  200             int talentCount = _talentService.GetTalents().Count();
  201             _talentService.SaveTalent(t);
  202             int talentCount2 = _talentService.GetTalents().Count();
  203             Assert.IsTrue(talentCount2 == talentCount + 1);
  204
  205             Talent t2 = new Talent();
  206             t2.Id = newId;
  207             t2.FirstName = "Walter";
  208             t2.LastName = "Payton";
  209
  210             int talentCount3 = _talentService.GetTalents().Count();
  211             _talentService.SaveTalent(t2);
  212             int talentCount4 = _talentService.GetTalents().Count();
  213             Assert.IsTrue(talentCount4 == talentCount3 + 1);
  214         }
  215
  216         [TestMethod]
  217         public void TalentServiceShouldUpdateTalentOnSave()
  218         {
  219             const string newLastName = "Payton";
  220             Talent t = _talentService.GetTalents().Where(x => x.Id == 5).SingleOrDefault();
  221             t.LastName = newLastName;
  222             _talentService.SaveTalent(t);
  223             Talent newt = _talentService.GetTalents().Where(x => x.Id == 5).SingleOrDefault();
  224             Assert.AreEqual(newLastName, newt.LastName); 
  225         }

File uploading - howto

File uploading to a database was easy to implement with the help of this post
thanks aspcode.net. I am using linq to sql, so I had to modify a few things. Here is my code.

private IEnumerable<Report> cReport
{
    get { return (IEnumerable<Report>)this.Session["cReport"]; }
    set { this.Session["cReport"] = (IEnumerable<Report>)value; }
}
private ReportContext ctxReport
{
    get { return (ReportContext)this.Session["ctxReport"]; }
    set { this.Session["ctxReport"] = (ReportContext)value; }
}

protected void InsertButton_Click(object sender, EventArgs e)
{
    this.Page.Validate();
    if (this.Page.IsValid)
    {
        FileUpload fu = ((FileUpload)this.fvReport.FindControl("fuFile"));
 
        byte[] bData = new byte[fu.PostedFile.ContentLength];
        fu.PostedFile.InputStream.Read(bData, 0, fu.PostedFile.ContentLength);
 
        //Retrieve filename
        System.IO.FileInfo oInfo = new System.IO.FileInfo(fu.PostedFile.FileName); 
        xxx.TourAdmin.Data.Report rep = new xxx.TourAdmin.Data.Report();
 
        rep.active = true;
        rep.FileLength = fu.PostedFile.ContentLength;
        rep.FileName = oInfo.Name;
        rep.ReportData = bData; 
        this.ctxReport.Report.InsertOnSubmit(rep);
 
        this.ctxReport.SaveAll(); 
    }
    this.gvReports.DataBind();
}

Tuesday, November 25, 2008

one nice looking blog


Marc Grabanski's blog is both informative and a good looking. Dry code will get there soon. check out his datepicker styles. Thanks Marc.

Monday, November 24, 2008

The Future of Web Development


.Net Rocks on The Future of Web Development. Anytime the DotNetDude (Miguel Castro)  is on, you know it's gonna be good. Thank you to just Carl this time for another great show.

Saturday, November 22, 2008

paint.net


It's no photoshop, but this is a nice free upgrade to windows paint. Scott Hanselman talks to the developer about creating installers for major products.


Wednesday, November 19, 2008

Google Font


click this link for your name in google font http://googlefont.com/

Tuesday, November 18, 2008

Don't repeat yourself

I am way overdue for a definition of D.R.Y. Code. here it is according to wikipedia
"Don't Repeat Yourself (DRY, also known as Single Point of Truth) is a process philosophy aimed at reducing duplication, particularly in computing. The philosophy emphasizes that information should not be duplicated, because duplication increases the difficulty of change, may decrease clarity, and leads to opportunities for inconsistency. "http://en.wikipedia.org/wiki/Don't_repeat_yourself

Monday, November 17, 2008

jQuery UI datepicker

jQuery UI is pretty sweet. The datepicker alone is worth using.
you can demo it here.

Thursday, November 13, 2008

.Net Rocks on Being a Professional


.Net Rocks it one of my favorite podcast shows. I had to break it up into 4 segments of driving. (I might need to move farther from work) This episode talks about creating clean code. Thank you Carl and Richard for another great show.
Bob Martin (Uncle Bob) on Being a Professional!

Saturday, November 8, 2008

Be a Better Developer in Six Months


you can always count on hanselminutes for a good show. Scott Hanselman tries not to waste your time. Check out his show on how to be a better developer here.
http://www.hanselminutes.com/default.aspx?showID=90
http://www.hanselman.com/blog/HanselminutesPodcast72BeABetterDeveloperInSixMonths.aspx

Friday, November 7, 2008

css styles (success, notice, and error div styles)

here are some nice looking css div styles for messages

this is success

this is notice

this is error

<div class="success">this is success </div>
<div class="notice">this is notice </div>
<div class="error">this is error</div>

.label { font-weight: bold; }
.error, .notice, .success, .help { padding: .8em; margin-bottom: 1em; border: 2px solid #ddd; }
.error { background: #FBE3E4; color: #D12F19; border-color: #FBC2C4; }
.notice { background: #FFF6BF; color: #817134; border-color: #FFD324; }
.success, .help { background: #E6EFC2; color: #529214; border-color: #C6D880; }

.error a { color: #D12F19; }
.notice a { color: #817134; }
.success a, .help a { color: #529214; }
 
.error ul { margin:10px; padding:10px;}
.notice ul { margin:10px; padding:10px;}
.success ul  { margin:10px; padding:10px;}
.help ul { margin:10px; padding:10px;}

http://drycodepages.googlepages.com/cssdivstylespart2

The Science of a Great User Experience

dnrTV (Dot Net Rocks TV) presents Mark Miller on The Science of a Great User Experience

Mark Miller on The Science of a Great User Experience Part 1
  and here is Part 2

Thursday, November 6, 2008

Halloween ladybug

here is elli as a ladybug

silverlight deep zoom

http://memorabilia.hardrock.com/
hardrock memorabilia
press the 'v' key and zoom out from there

Wednesday, November 5, 2008

asp.net handlers serving xml

your handler code
namespace XXXX.TourAdmin.Web.Admin
{
    /// 
    /// Summary description for $codebehindclassname$
    /// 
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class VideoHandler : IHttpHandler
    {
 
        public void ProcessRequest(HttpContext context)
        {
            //context.Response.ContentType = "text/plain";
            context.Response.ContentType = "UTF-8";
            context.Response.Write(this.GetVideoXml());
        }
 
        protected string GetVideoXml()
        {
            VideoContext vc = new VideoContext();
            var videos = from v in vc.Videos
                         select new 
                         {
                             VideoClip = v.FileLocation,
                             Title = v.Title,
                             Date = v.VideoDate,
 
                         };
 
            XDocument xmlDoc = new XDocument();
            XElement xEleVideos = new XElement("videos");
            xmlDoc.Add(xEleVideos); 
            foreach (var v in videos)
            {
                xEleVideos.Add(new XElement("video",  new XAttribute("VideoClip", v.VideoClip),
                    new XAttribute("Title", v.Title), new XAttribute("Copy", v.Date)));
            }
            string s = xmlDoc.ToString();
            return s;
        }
 
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
here is the data:



TitleFileLocationVideoDateactive
Miami, Florida200809142009-02-12 00:00:001

now put the url in the address bar
http://localhost/XXXX.TourAdmin.Web/Admin/VideoHandler.ashx
<videos>
  <video VideoClip="20080914" Title="Miami, Florida" copy="2009-02-12T00:00:00" />
<videos>
Props to Lewis

Contributors