using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcResourceLang.Models;

namespace MvcResourceLang.Controllers {
	public class AccountController : Controller {
		public ActionResult Logon() {
			return View();
		}
		[HttpPost]
		public ActionResult Logon(FormCollection form) {
			if (!string.IsNullOrEmpty(form["UserName"]) && !string.IsNullOrEmpty(form["pwd"]))
				return RedirectToAction("Index", "Default", null);
			else
				//return Content("<script>alert('" + LangHelper.GetLangbyKey(null, "LogonErrorMsgDisplay") + "')</script>");
				return View();
		}

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

		[HttpPost]
		public JsonResult Register(string username, string pwd) {
			// to do sth
			if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(pwd)) {
				return Json(new { msg = LangHelper.GetLangbyKey(null, "RegisterSucDisplay") }, JsonRequestBehavior.AllowGet);
			} else {
				return Json(new { msg = LangHelper.GetLangbyKey(null, "RegisterFailDisplay") }, JsonRequestBehavior.AllowGet);
			}
		}
	}
}
