public ActionResult Register(string fname, string lname, string jobdesc, HttpPostedFileBase photo, string mobile, string role, string username, string password, string email) { byte[] photos = null; if (photo != null) { try { string path = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(photo.FileName)); photo.SaveAs(path); using (MemoryStream ms = new MemoryStream()) { photo.InputStream.CopyTo(ms); photos = ms.GetBuffer(); } ViewBag.Message = "File uploaded successfully"; } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } try { S_ACTORS act = new S_ACTORS() { FNAME = fname, LNAME = lname, JOB_DESC = jobdesc, MOBILE = Int32.Parse(mobile), AROLE = role, USERNAME = username, PASSWORD = password, EMAIL = email }; DataBaseFuncController db = new DataBaseFuncController(); if (db.AddActor(act) == "Done, Updated") { return(Redirect("Index")); } else { return(HttpNotFound()); } } catch (Exception ex) { return(HttpNotFound()); Console.WriteLine(ex); } }
public JsonResult Register(string fname, string lname, string jobdesc, HttpPostedFileBase photo, string mobile, string role, string username, string password, string email) { byte[] photos = null; if (photo != null) { try { string path = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(photo.FileName)); photo.SaveAs(path); using (MemoryStream ms = new MemoryStream()) { photo.InputStream.CopyTo(ms); photos = ms.GetBuffer(); } ViewBag.Message = "File uploaded successfully"; } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } try { S_ACTORS act = new S_ACTORS() { FNAME = fname, LNAME = lname, JOB_DESC = jobdesc, MOBILE = Int32.Parse(mobile), AROLE = role, USERNAME = username, PASSWORD = password, EMAIL = email }; DataBaseFuncController db = new DataBaseFuncController(); var allactors = db.GetAllActors(); foreach (var element in allactors) { if (username == element.USERNAME) { return(Json(11, JsonRequestBehavior.AllowGet)); } } foreach (var element in allactors) { if (email == element.EMAIL) { return(Json(12, JsonRequestBehavior.AllowGet)); } } if (db.AddActor(act) == "Done, Updated") { var result = 0; return(Json(result, JsonRequestBehavior.AllowGet)); } else { var result = 1; return(Json(result, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(ex.ToString(), JsonRequestBehavior.AllowGet)); } }