using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ConditionalAttributes;
using MvcApplication10.Models;

namespace MvcApplication10.Controllers
{
    public class HomeController : Controller, IConditionalAttribute
    {
        //
        // GET: /Home/

     
        public JsonResult LoginIDExists(string LoginID)
        {
            bool valid = LoginID != "1";
            return Json(valid, JsonRequestBehavior.AllowGet);
        }

        public JsonResult NameExists(string Name)
        {
            bool valid = Name != "Talal";
            return Json(valid, JsonRequestBehavior.AllowGet);
        }

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

        [HttpPost]
        public ActionResult Index(Person person)
        {
            if (!ModelState.IsValid)
            {

                return View(person);
            }
            else
            {
                return RedirectToAction("Modify", person);
            }
        }

        public ActionResult Modify(Person person)
        {
            return View("");
        }

        public bool ApplyAttribute(string action, string field, ConditionalAttribute attr, ModelMetadata metadata, ControllerContext context, bool applyAttribute)
        {
            return applyAttribute;
        }
    }
}
