public ActionResult Edit([Bind(Include = "TP_ID,image_url,is_Admin,tp_password,tp_fname,tp_lname,tp_email,tp_posting")] TraficPolice traficPolice, HttpPostedFileBase profilepic, string State) { if (ModelState.IsValid) { if (profilepic != null) { if (profilepic.ContentType == "image/jpg" || profilepic.ContentType == "image/jpeg" || profilepic.ContentType == "image/png") { string ext = System.IO.Path.GetExtension(profilepic.FileName); profilepic.SaveAs(Server.MapPath("/") + "/Content/PolicememberProfilePhoto/" + traficPolice.TP_ID + ext); traficPolice.image_url = traficPolice.TP_ID + ext; } else { TempData["ErrorMsg"] = "image must be in formate of jpg/png/jpeg only"; return(RedirectToAction("Edit", new { id = traficPolice.TP_ID })); } } else { } traficPolice.tp_posting = State.Substring(2).ToUpper(); traficPolice.tp_fname = traficPolice.tp_fname.ToUpper(); traficPolice.tp_lname = traficPolice.tp_lname.ToUpper(); db.Entry(traficPolice).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(traficPolice)); }