public async Task<ActionResult> Login(string username, string password) { var refundAppRepo = new RefundApplicationRepository(); var existing = await refundAppRepo.FindIRD(username); if (existing.Count > 0) { Session["IRDNumber"] = username; Session["Title"] = existing.FirstOrDefault().Title; Session["FirstName"] = existing.FirstOrDefault().FirstName; Session["LastName"] = existing.FirstOrDefault().LastName; Session["Email"] = existing.FirstOrDefault().Email; Response.StatusCode = (int)HttpStatusCode.OK; return Json(new { success = true, irdNumber = Session["IRDNumber"], title = Session["Title"], firstName = Session["FirstName"], lastName = Session["LastName"], email = Session["Email"], }, JsonRequestBehavior.AllowGet); } else { Response.StatusCode = (int)HttpStatusCode.BadRequest; return Json(new { success = false, responseText = "User already exist." }, JsonRequestBehavior.AllowGet); } }
public async Task<ActionResult> Register(string username, string password) { var refundAppRepo = new RefundApplicationRepository(); var existing = await refundAppRepo.FindIRD(username); if (existing.Count == 0) { var refunApp = new RefundApplication { IRDNumber = username, Password = password }; await refundAppRepo.CreateSync(refunApp); Session["IRDNumber"] = username; Response.StatusCode = (int)HttpStatusCode.OK; return Json(new { success = true, responseText = "Added." }, JsonRequestBehavior.AllowGet); } else { Response.StatusCode = (int)HttpStatusCode.BadRequest; return Json(new { success = false, responseText = "User already exist." }, JsonRequestBehavior.AllowGet); } }