public ActionResult Settings(Hod hod) { SetHodDetails(); hod.ID = HodDetails.ID; hod.DeptID = HodDetails.DeptID; hod.Subject = HodDetails.Subject; string ImgUrl; try { string uniqueFileName = Guid.NewGuid().ToString() + "_" + hod.Image.FileName; if (hod.Image != null) { string path = Server.MapPath("/Images/HOD/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } hod.Image.SaveAs(path + uniqueFileName); ImgUrl = "/Images/HOD/" + uniqueFileName; } else { ImgUrl = "noupdate"; } } catch { ImgUrl = "noupdate"; } hod.ImgUrl = ImgUrl; PrinciUtil princiUtil = new PrinciUtil(); if (princiUtil.UpdateHod(hod)) { Session["Notification"] = 1; } else { Session["Notification"] = 2; } return(RedirectToAction("Settings")); }
public ActionResult EditHOD(Hod hod) { string ImgUrl; try { string uniqueFileName = Guid.NewGuid().ToString() + "_" + hod.Image.FileName; if (hod.Image != null) { string path = Server.MapPath("/Images/HOD/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } hod.Image.SaveAs(path + uniqueFileName); ImgUrl = "/Images/HOD/" + uniqueFileName; } else { ImgUrl = "noupdate"; } } catch { ImgUrl = "noupdate"; } hod.ImgUrl = ImgUrl; PrinciUtil princiUtil = new PrinciUtil(); if (princiUtil.UpdateHod(hod)) { Session["Notification"] = 3; } else { Session["Notification"] = 4; } return RedirectToAction("HOD"); }