Click here to Skip to main content
15,896,557 members
Articles / Web Development / ASP.NET

Custom Membership Providers - Task Manager

Rate me:
Please Sign up or sign in to vote.
4.17/5 (5 votes)
9 Apr 2011CPOL5 min read 56.1K   2K   47  
This article extends what was built in the previous article. This is a task manager application that uses the custom provider designed in the last part.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TestMvcApplication.Models;
using CustomMembership.Models;

namespace CustomMembership.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            return View();
        }

        [Authorize]
        public ActionResult Protected()
        {
            return View();
        }

        [Authorize]
        public ActionResult Tasks()
        {
            UserIdentity identity = (UserIdentity)User.Identity;
            Task _task = new Task();
            return View(_task.GetTasksByUserID(int.Parse(identity.UserId)));
        }

        [Authorize]
        public ActionResult AddTask()
        {
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult AddTask(TaskObj task)
        {
            UserIdentity identity = (UserIdentity)User.Identity;
            Task _task = new Task();
            task.UserID = int.Parse(identity.UserId);
            task.TaskDateTime = DateTime.Now;
            _task.AddTask(task);

            return View(task);
        }
    }
}

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
Just another passionate software developer!

Some of the contributions to the open source world - a blog engine written in MVC 4 - sBlog.Net. Check it out here. For the codeproject article regarding sBlog.Net click here!

(Figuring out this section!)

Comments and Discussions