public ActionResult Items(int id, int formId)
        {
            RepositoryViews repository = new RepositoryViews();
            Models.View view = repository.Get(id);
            view.Group.DefaultFormId = formId;
            RepositoryMapguide mapguide = new RepositoryMapguide();
            DataListModel model = null;

            if (view.ViewTypeId == 5 || !User.Identity.IsAuthenticated)
            {
                model = mapguide.GetList(view, "");
            }
            else
            {
                model = mapguide.GetList(view, Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());
            }
            return PartialView("System_Items", model);
        }
 public ActionResult Index(int id, int? itemId, int? formId, string column, bool? ascending)
 {
     RepositoryViews repositoryViews = new RepositoryViews();
     Models.View view = repositoryViews.Get(id);
     if (formId.HasValue)
         view.Group.DefaultFormId = formId.Value;
     if (itemId.HasValue)
     {
         //2 = Edit
         //3 = Delete
         //4 = Details
         if (view.ViewTypeId == 2 || view.ViewTypeId == 3 || view.ViewTypeId == 4)
         {
             RepositoryMapguide mapguide = new RepositoryMapguide();
             DataViewModel model = new DataViewModel()
             {
                 ItemId = itemId.Value,
                 View = view,
                 Form = view.Group.Forms.Single(m => m.FormId == view.Group.DefaultFormId)
             };
             model = mapguide.Get(model);
             return View(view.Name, model);
         }
     }
     else
     {
         //1 = Create
         if (view.ViewTypeId == 1)
         {
             DataViewModel model = new DataViewModel
             {
                 View = view,
                 Form = view.Group.Forms.SingleOrDefault(m => m.FormId == view.Group.DefaultFormId),
                 Date = DateTime.Now,
                 UniqueId = Guid.NewGuid().ToString()
             };
             if (User.Identity.IsAuthenticated)
             {
                 model.UserName = User.Identity.Name;
                 model.UserId = Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString();
                 UserProfile profile = UserProfile.GetUserProfile(User.Identity.Name);
                 RepositoryCompanies rc = new RepositoryCompanies();
                 Company company = rc.Get(profile.CompanyId);
                 if (company != null)
                     model.Company = company.Name;
             }
             return View(view.Name, model);
         }
         //5 = List All
         else if (view.ViewTypeId == 5)
         {
             RepositoryMapguide mapguide = new RepositoryMapguide();
             DataListModel model = mapguide.GetList(view, "");
             return View(view.Name, model);
         }
         //6 = List My
         else if (view.ViewTypeId == 6)
         {
             RepositoryMapguide mapguide = new RepositoryMapguide();
             DataListModel model = null;
             if (User.Identity.IsAuthenticated)
             {
                 model = mapguide.GetList(view, Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());
             }
             else
             {
                 model = mapguide.GetList(view, "");
             }
             return View(view.Name, model);
         }
     }
     return View("Error");
 }