public JsonResult <object> UpdateUserDetail([FromBody] JObject json) { StudentVM re = JsonConvert.DeserializeObject <StudentVM>(json.ToString()); var obj = new object(); Dictionary <string, object> dic = new Dictionary <string, object>(); string Image1 = re.ProfilePic; string Image2 = re.Document1; string Image3 = re.Document2; string SavePath1 = ""; string SavePath2 = ""; string SavePath3 = ""; try { if (!string.IsNullOrEmpty(Image1)) { var postedFile = Image1; if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/Document/ProfilePic/"))) { Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/Document/ProfilePic/")); } string ImagePath1 = HttpContext.Current.Server.MapPath("~/Document/ProfilePic/") + re.FirstName + re.LastName + ".jpg"; SavePath1 = "/Document/ProfilePic/" + re.FirstName + re.LastName + ".jpg"; if (File.Exists(ImagePath1)) { File.Delete(ImagePath1); } byte[] Image1D = Convert.FromBase64String(Image1.ToString()); Stream stmImage1D = new MemoryStream(Image1D); Bitmap originalBMP1 = new Bitmap(stmImage1D); originalBMP1.Save(ImagePath1); } if (!string.IsNullOrEmpty(Image2)) { var postedFile = Image2; if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/Document/Documents/"))) { Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/Document/Documents/")); } string ImagePath2 = HttpContext.Current.Server.MapPath("~/Document/Documents/") + re.FirstName + re.LastName + "Doc1.jpg"; SavePath2 = "/Document/Documents/" + re.FirstName + re.LastName + "Doc1.jpg"; if (File.Exists(ImagePath2)) { File.Delete(ImagePath2); } byte[] Image2D = Convert.FromBase64String(Image2.ToString()); Stream stmImage2D = new MemoryStream(Image2D); Bitmap originalBMP2 = new Bitmap(stmImage2D); originalBMP2.Save(ImagePath2); } if (!string.IsNullOrEmpty(Image3)) { var postedFile = Image3; if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/Document/Documents/"))) { Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/Document/Documents/")); } string ImagePath3 = HttpContext.Current.Server.MapPath("~/Document/Documents/") + re.FirstName + re.LastName + "Doc2.jpg"; SavePath3 = "/Document/Documents/" + re.FirstName + re.LastName + "Doc2.jpg"; if (File.Exists(ImagePath3)) { File.Delete(ImagePath3); } byte[] Image3D = Convert.FromBase64String(Image3.ToString()); Stream stmImage3D = new MemoryStream(Image3D); Bitmap originalBMP3 = new Bitmap(stmImage3D); originalBMP3.Save(ImagePath3); } using (StudentsEntities context = new StudentsEntities()) { var result = context.StudentUpdate(re.StudentId, re.FirstName, re.LastName, re.DOB, re.PhoneNo, re.Address, re.BloodGroup, SavePath1, re.FatherName, re.category, re.MainSubject, SavePath2, SavePath3, re.Password, re.Obtional1, re.Obtional2, re.Obtional3, re.Obtional4, re.Role, Convert.ToBoolean(0), re.SubjectId, re.BloodGroupId); dic.Add("Status", "1"); dic.Add("Message", "Success"); } } catch (Exception E) { dic.Add("Message", E.Message); dic.Add("Status", "0"); } obj = dic; return(Json(obj)); }