public ActionResult UpdateStudent(Student objStd) { bool status = false; string message = "failed"; if (objStd.StudentName != null && objStd.UploadImage != null) { string fileName = Path.GetFileNameWithoutExtension(objStd.UploadImage.FileName); string extension = Path.GetExtension(objStd.UploadImage.FileName); fileName = fileName + DateTime.Now.ToString("yymmssff") + extension; objStd.StudentPicPath = fileName; objStd.UploadImage.SaveAs(Path.Combine(Server.MapPath("~/AppFile/Images"), fileName)); var result = stdntbll.UpdateStudent(objStd); if (result > 0) { status = true; message = "successfully updated"; } } else { var result = stdntbll.UpdateStudent(objStd); if (result > 0) { status = true; message = "successfully updated"; } } return(new JsonResult { Data = new { status = status, message = message } }); }