public ActionResult updateLeaves(ApplyLeave applyLeave, HttpPostedFileBase file) { int id = 0; id = Convert.ToInt32(Session["id"]); int rowAffected = 0; byte[] imageData = null; ApplyLeave obj = new ApplyLeave(); var list = obj.getTypeOfLeave(); obj.TOL = obj.GetSelectListItem(list); string name = Path.GetExtension(file.FileName).ToLower(); if (file.ContentLength > 0 && (name.Equals(".jpg") || name.Equals(".jpeg") || name.Equals(".png"))) { using (var binaryReader = new BinaryReader(file.InputStream)) { imageData = binaryReader.ReadBytes(file.ContentLength); } applyLeave.MSID = Session["MSID"].ToString(); rowAffected = ApplyLeave.updateLeavesToDB(applyLeave.MSID, applyLeave.StartDate, applyLeave.EndDate, applyLeave.TypeOfLeaves, applyLeave.TotalLeaves, applyLeave.Reason, applyLeave.Status, imageData, id); } if (rowAffected == 1) { ViewBag.Message = "Success"; ApplyLeave applyLeaves = new ApplyLeave(); Dictionary <string, string> toGetEmailDetails = applyLeaves.toGetEmailDetails(applyLeave.MSID); Dictionary <string, string> toGetNameDetails = applyLeaves.toGetNameDetails(applyLeave.MSID); mailSent = emailToSupervisor(toGetEmailDetails, toGetNameDetails, applyLeave); var message = " Leave Updated Successfully "; return(RedirectToAction("ViewLeaves1", "ApplyLeave", new { whatever = message })); } else { return(RedirectToAction("ViewLeaves", "ApplyLeave")); } }