public ActionResult AddDoctor(tblEmployee employee, int?Doctor_id) { int hospital_id = 0; HttpCookie cookie = HttpContext.Request.Cookies["AdminCookies"]; if (cookie != null) { hospital_id = Convert.ToInt32(cookie.Values["hospital_id"]); } employee.hospital_id = hospital_id; try { string file_name = ""; string hdnImages = Request.Form["hdnImages"]; string hdnimageName = Request.Form["hdnimageName"]; employee.EmployeeTypeID = 1; employee.Is_active = true; if (employee.Gender == "1") { // employee.Gender = "Male"; } if (employee.Gender == "2") { // employee.Gender = "Female"; } if (hdnImages != "") { String path = Server.MapPath("/assets/images/Doctor_Images/"); List <string> Imglst = new List <string>(); string[] stringSeparators = new string[] { "#####" }; Imglst = hdnImages.Split(stringSeparators, StringSplitOptions.None).ToList(); int a = Imglst.Count(); Imglst.RemoveAt(a - 1); string Images = null; foreach (var item in Imglst) { if (!item.Contains("/images")) { Images += new GernalFunction().ImageCroping(item, "/assets/images/Doctor_Images/"); Images += ","; } else { Images += System.IO.Path.GetFileName(item); Images += ","; } } List <string> splitimgs = new List <string>(); splitimgs = Images.Split(',').ToList(); int b = splitimgs.Count(); splitimgs.RemoveAt(b - 1); foreach (var item in splitimgs) { file_name = new GernalFunction().Resize_MedImage(path, item, path);//Medium images } } else if (hdnimageName != null && hdnimageName != "") { file_name = hdnimageName; } employee.Image = file_name; if (Doctor_id != null && Doctor_id != 0) { employee.ID = Convert.ToInt32(Doctor_id); new DoctorsDAL().UpdateRecord(employee); TempData["AlertTask"] = "Doctor Updated successfully"; } else { new DoctorsDAL().InsertRecord(employee); TempData["AlertTask"] = "Doctor added successfully"; } // TODO: Add insert logic here return(Redirect("/doctors")); } catch (Exception ex) { string err = ex.ToString(); TempData["AlertTask"] = "Error Occured."; return(Redirect("/")); } }
public ActionResult AddUser(User users, string Active) { new GernalFunction().CheckAdminLogin(); if (users.Image != null) { if (!users.Image.Contains("Resources/AdminPictures")) { string FileName = ""; string HostedFilePath = ""; users.Image = GernalFunction.ImageCroping(users.Image, "/Resources/AdminPictures/", false, out HostedFilePath, out FileName); } else { users.Image = Path.GetFileName(users.Image); } } else { users.Image = "NoImage.jpg"; } if (Active == "on") { users.IsActive = true; } else { users.IsActive = false; } if (Convert.ToInt32(Request.QueryString["ID"]) != 0 && Request.QueryString["ID"] != null && Request.QueryString["ID"] != "") { users.ID = Convert.ToInt32(Request.QueryString["ID"]); new UserModel().Update(users); TempData["AlertTask"] = "Record Successfully Update"; } else { #region Username and Email Exists bool Email = new UserModel().EmailExist(users.Email); ViewBag.Exists = ""; if (Email == true) { bool username = new UserModel().UsernameExist(users.UserName); if (username == false) { ViewBag.Exists = "Username"; } } else { ViewBag.Exists = "Email"; } if (ViewBag.Exists != "") { return(View()); } #endregion users.IsAdmin = false; new UserModel().Save(users); TempData["AlertTask"] = "Record Successfully Saved"; } return(RedirectToAction("ManageUsers")); }