예제 #1
0
 public ActionResult Register(RegisterModel model)
 {
     if (ModelState.IsValid)
     {
         var status = InsertMethods.RegisterNewUser(model);
         if (status == (int)Registration.Success && CheckMethods.IsUserExists(model.Login))
         {
             FormsAuthentication.SetAuthCookie(model.Login, true);
             return(RedirectToAction("Index", "Account"));
         }
     }
     ViewBag.Error = "Already exists";
     return(View("~/Views/Register/Registration.cshtml", model));
 }
예제 #2
0
        public JsonResult PostRegisterUser(string username, string name, string surname, string password, string email)
        {
            InsertMethods.RegisterNewUser(username, name, surname, password, email);
            if (CheckMethods.IsUserExists(username))
            {
                JsonResult res = new JsonResult()
                {
                    Data = new { status = "succesful" }
                };
                return(res);
            }

            var err = new Error()
            {
                ErrorCode = HttpStatusCode.InternalServerError, Message = "Server error"
            };

            JsonConvert.SerializeObject(err);
            return(new JsonResult()
            {
                Data = err
            });
        }