public ActionResult Form(Users users) { if (ModelState.IsValid) { UserBusinessLayer userBusinessLayer = new UserBusinessLayer(); userBusinessLayer.AddUser(users); //return RedirectToAction("Display"); } return(PartialView()); }
public HttpResponseMessage NewUser(HttpRequestMessage request) { if (Request.Method == HttpMethod.Options) { return(new HttpResponseMessage(HttpStatusCode.OK)); } WebServiceResult retVal = new WebServiceResult() { Message = "OK", Result = "" }; UserBusinessLayer bl = new UserBusinessLayer(); try { string[] json = request.Content.ReadAsStringAsync().Result.Split('='); Dictionary <string, string> result = new Dictionary <string, string>(); if (json[0] != null && json[0] == "data") { result = JsonConvert.DeserializeObject <Dictionary <string, string> >(HttpUtility.UrlDecode(json[1])); User user = new User() { Name = Convert.ToString(result["Name"]), FullName = Convert.ToString(result["FullName"]), Address = Convert.ToString(result["Address"]), PassHash = Convert.ToString(result["PassHash"]), Email = Convert.ToString(result["Email"]) }; retVal = bl.AddUser(user); } var status = HttpStatusCode.OK; if (retVal.Message != "OK") { status = HttpStatusCode.InternalServerError; } return(new HttpResponseMessage(status) { Content = new StringContent(JsonConvert.SerializeObject(retVal), Encoding.UTF8, "application/json") }); } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(JsonConvert.SerializeObject(ex), Encoding.UTF8, "application/json") }); } }
public ActionResult Create_Post() { User usersObj = new User(); TryUpdateModel(usersObj); if (ModelState.IsValid) { UserBusinessLayer userBusinessLayerObj = new UserBusinessLayer(); userBusinessLayerObj.AddUser(usersObj); Session["username"] = usersObj.username; return(Redirect("/Home/Index")); } return(View()); }