public ActionResult SaveSystemConfiguration(ManageSystemConfiguration model) { int id = (int)Session["super admin"]; if (!ModelState.IsValid) { return(View("ManageSystemConfiguration", model)); } _context.RemoveSystemConfig(); SystemConfiguration Configuration1 = new SystemConfiguration { key = "Support Email Address", Value = model.SupportEmail, CreatedDate = DateTime.Now, CreatedBy = id, ModifiedDate = DateTime.Now, ModifiedBy = id }; _context.AddSystemConfig(Configuration1); SystemConfiguration Configuration2 = new SystemConfiguration { key = "Support Phone Number", Value = model.SupportPhoneNo, CreatedDate = DateTime.Now, CreatedBy = id, ModifiedDate = DateTime.Now, ModifiedBy = id }; _context.AddSystemConfig(Configuration2); SystemConfiguration Configuration3 = new SystemConfiguration { key = "Email Addresses For Notify", Value = model.EmailForEvent, CreatedDate = DateTime.Now, CreatedBy = id, ModifiedDate = DateTime.Now, ModifiedBy = id }; _context.AddSystemConfig(Configuration3); SystemConfiguration Configuration4 = new SystemConfiguration { key = "Facebook Url", Value = model.FacebookURL, CreatedDate = DateTime.Now, CreatedBy = id, ModifiedDate = DateTime.Now, ModifiedBy = id }; _context.AddSystemConfig(Configuration4); SystemConfiguration Configuration5 = new SystemConfiguration { key = "Twitter Url", Value = model.TwitterURL, CreatedDate = DateTime.Now, CreatedBy = id, ModifiedDate = DateTime.Now, ModifiedBy = id }; _context.AddSystemConfig(Configuration5); SystemConfiguration Configuration6 = new SystemConfiguration { key = "LinkedIn Url", Value = model.LinkedInURL, CreatedDate = DateTime.Now, CreatedBy = id, ModifiedDate = DateTime.Now, ModifiedBy = id }; _context.AddSystemConfig(Configuration6); if (model.ImageForNotes != null) { string pic = Path.GetExtension(model.ImageForNotes.FileName); if (pic.ToLower() != ".jpg" && pic.ToLower() != ".jpeg") { ModelState.AddModelError("note pic format", "please upload .jpg or .jpeg file."); return(View("ManageSystemConfiguration", model)); } var noteImageName = "note_" + Path.GetFileName(model.ImageForNotes.FileName); string imgPath = Path.Combine(Server.MapPath("~/DefaultImages/"), noteImageName); model.ImageForNotes.SaveAs(imgPath); SystemConfiguration Configuration7 = new SystemConfiguration { key = "Default Image For Notes", Value = noteImageName, CreatedDate = DateTime.Now, CreatedBy = id, ModifiedDate = DateTime.Now, ModifiedBy = id }; _context.AddSystemConfig(Configuration7); } if (model.ImageForUser != null) { string pic = Path.GetExtension(model.ImageForUser.FileName); if (pic.ToLower() != ".jpg" && pic.ToLower() != ".jpeg") { ModelState.AddModelError("user pic format", "please upload .jpg or .jpeg file."); return(View("ManageSystemConfiguration", model)); } var userImageName = "user" + Path.GetFileName(model.ImageForUser.FileName); string imgPath = Path.Combine(Server.MapPath("~/DefaultImages/"), userImageName); model.ImageForUser.SaveAs(imgPath); SystemConfiguration Configuration8 = new SystemConfiguration { key = "Default Image For User", Value = userImageName, CreatedDate = DateTime.Now, CreatedBy = id, ModifiedDate = DateTime.Now, ModifiedBy = id }; _context.AddSystemConfig(Configuration8); } _context.UpdateUp(); return(RedirectToAction("Dashboard", "Admin")); }