// GET: Doctor/Create public ActionResult Add() { DoctorDepartment viewmodel = new DoctorDepartment(); viewmodel.departments = db.Departments.ToList(); return(View(viewmodel)); }
public ActionResult DeleteConfirmed(int id) { DoctorDepartment doctorDepartment = db.DoctorDepartment.Find(id); db.DoctorDepartment.Remove(doctorDepartment); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult> CreateUser(CreateUserViewModel model) { // if (model.Role == "Receptionist") // {[email protected] // ModelState["model.DepartmentId"].Errors.Clear(); // ModelState.Clear(); // } IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors); string finalPath = ""; if (model.ProfilePicture != null) { string fileName = Path.GetFileNameWithoutExtension(model.ProfilePicture.FileName); string extension = Path.GetExtension(model.ProfilePicture.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; finalPath = "~/Images/" + fileName; fileName = Path.Combine(Server.MapPath("~/Images"), fileName); model.ProfilePicture.SaveAs(fileName); } if (ModelState.IsValid || allErrors.Count() == 1) { var user = new ApplicationUser { FullName = model.FullName, Gender = model.Gender, DateOfBirth = model.DateOfBirth, Address = model.Address, Mobile = model.Mobile, UserName = model.Email, Email = model.Email, ProfileImagePath = finalPath }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await UserManager.AddToRoleAsync(user.Id, model.Role); if (model.Role == "Doctor") { var doctorDepartment = new DoctorDepartment { DepartmentId = model.DepartmentId, DoctorUserId = user.Id }; _context.DoctorDepartments.Add(doctorDepartment); await _context.SaveChangesAsync(); } //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Admin")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult Edit([Bind(Include = "DoctorDepartmentId,DoctorDepartmentName")] DoctorDepartment doctorDepartment) { if (ModelState.IsValid) { db.Entry(doctorDepartment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(doctorDepartment)); }
public ActionResult Create([Bind(Include = "DoctorDepartmentId,DoctorDepartmentName")] DoctorDepartment doctorDepartment) { if (ModelState.IsValid) { db.DoctorDepartment.Add(doctorDepartment); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(doctorDepartment)); }
// GET: DoctorDepartment/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DoctorDepartment doctorDepartment = db.DoctorDepartment.Find(id); if (doctorDepartment == null) { return(HttpNotFound()); } return(View(doctorDepartment)); }
public List <DoctorDepartment> GetDoctorListWithDepartments() { string connectionString = ConfigurationManager.ConnectionStrings["HospitalConnectionString"].ConnectionString; SqlConnection sqlConnection = new SqlConnection(connectionString); string query = "SELECT * FROM DoctorDepartmentView"; SqlCommand sqlCommand = new SqlCommand(query, sqlConnection); sqlConnection.Open(); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); List <DoctorDepartment> doctorDepartmentList = new List <DoctorDepartment>(); while (sqlDataReader.Read()) { DoctorDepartment doctorDepartment = new DoctorDepartment(); doctorDepartment.Id = int.Parse(sqlDataReader["Id"].ToString()); doctorDepartment.DoctorName = sqlDataReader["DoctorName"].ToString(); doctorDepartment.DepartmentName = sqlDataReader["DepartmentName"].ToString(); doctorDepartmentList.Add(doctorDepartment); } return(doctorDepartmentList); }
// GET: Doctor/Edit/5 public ActionResult Update(string id) { bool admin = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(User.Identity.GetUserId()).is_admin; if (admin == true) { string query = "select * from doctors where doctorId =@id"; var Parameter = new SqlParameter("@id", id); Doctors doctors = db.Doctors.SqlQuery(query, Parameter).FirstOrDefault(); List <Department> departments = db.Departments.SqlQuery("select * from departments").ToList(); DoctorDepartment viewmodel = new DoctorDepartment(); viewmodel.departments = departments; viewmodel.Doctors = doctors; return(View(viewmodel)); } else { return(Redirect("https://localhost:44315/Error/Index")); } }
//[Authorize(Roles = "admin,hr")] public ActionResult Detail(int?id) { try { if (id == null) { return(RedirectToAction("Index")); } DoctorDepartment doctorDepartment = db.Doctors.Join(db.departments, doc => doc.Departmentid, dep => dep.departmentid, (doc, dep) => new DoctorDepartment { doctor = doc, department = dep }).Where(doc => doc.doctor.Doctorid == id).FirstOrDefault(); return(View(doctorDepartment)); } catch (SqlException sq) { ViewBag.SqlExceptionMessage = sq.Message; } catch (Exception e) { ViewBag.ExceptionMessage = e.Message; } return(View("~/Views/Errors/Details.cshtml")); }
protected override void Seed(HMS.Models.ApplicationDbContext context) { context.Departments.AddOrUpdate( d => d.Name, new Department { Name = "Emergency Care", Fee = 500, ShortDescription = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever.", IconCode = "ambulance-icon flaticon-icon-131071" }, new Department { Name = "Cardiology", Fee = 500, ShortDescription = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever.", IconCode = "ambulance-icon flaticon-icon-12625" }, new Department { Name = "ENT", Fee = 500, ShortDescription = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever.", IconCode = "ambulance-icon flaticon-icon-105385" }, new Department { Name = "Eye Care", Fee = 500, ShortDescription = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever.", IconCode = "ambulance-icon flaticon-icon-131019" }, new Department { Name = "Diabetes Care", Fee = 500, ShortDescription = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever.", IconCode = "ambulance-icon flaticon-icon-131019" }, new Department { Name = "Orthopedics", Fee = 500, ShortDescription = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever.", IconCode = "ambulance-icon flaticon-icon-105402" } , new Department { Name = "Pulmology", Fee = 500, ShortDescription = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever.", IconCode = "ambulance-icon flaticon-icon-45987" }, new Department { Name = "Child Care", Fee = 500, ShortDescription = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever.", IconCode = "ambulance-icon flaticon-icon-49091" } ); context.SaveChanges(); context.Events.AddOrUpdate( e => e.Title, new ProbableEvent { Title = "Free checkup in children day", EventDate = DateTime.Parse("2018-11-14"), ShortDescription = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever.", FeatureImagePath = "~/Images/event-1.jpg" }, new ProbableEvent { Title = "Free checkup in victory day", EventDate = DateTime.Parse("2018-12-16"), ShortDescription = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever.", FeatureImagePath = "~/Images/event-2.jpg" } ); context.SaveChanges(); context.Blogs.AddOrUpdate( e => e.Title, new Blog { Title = "Launched Child Care Department", AuthorId = "2e0602e9-d083-42c4-b9ec-b86cf88d4656", CreatedAt = DateTime.Today, Content = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever.", FeatureImagePath = "~/Images/blog-img-4.jpg" }, new Blog { Title = "New machines in Eye Care", AuthorId = "2e0602e9-d083-42c4-b9ec-b86cf88d4656", CreatedAt = DateTime.Today, Content = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever.", FeatureImagePath = "~/Images/blog-img-1.jpg" } ); context.SaveChanges(); context.Testimonials.AddOrUpdate( t => t.Name, new Testimonial { Name = "John Doe", Designation = "Engineer", Message = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever.", ProfileImagePath = "~/Images/test-client-1.jpg" }, new Testimonial { Name = "Jane Doe", Designation = "Reporter", Message = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever.", ProfileImagePath = "~/Images/test-client-2.jpg" } ); //Seeding Doctor Users var userStore = new UserStore <ApplicationUser>(context); var userManager = new UserManager <ApplicationUser>(userStore); if (!(context.Users.Any(u => u.UserName == "*****@*****.**"))) { var userToInsert = new ApplicationUser { UserName = "******", FullName = "John Doe", Gender = "Male", DateOfBirth = DateTime.Parse("1990-01-01"), Address = "sample address", Mobile = "01300111222", Email = "*****@*****.**", ProfileImagePath = "~/Images/dr-grid-1.jpg" }; var result = userManager.Create(userToInsert, "Password@123"); if (result.Succeeded) { userManager.AddToRole(userToInsert.Id, "Doctor"); var department = context.Departments.SingleOrDefault(d => d.Name == "Emergency Care"); var doctorDepartment = new DoctorDepartment { DepartmentId = department.DepartmentId, DoctorUserId = userToInsert.Id }; context.DoctorDepartments.AddOrUpdate(doctorDepartment); context.SaveChanges(); } } if (!(context.Users.Any(u => u.UserName == "*****@*****.**"))) { var userToInsert = new ApplicationUser { UserName = "******", FullName = "John Doe", Mobile = "01300111222", Email = "*****@*****.**", Gender = "Male", DateOfBirth = DateTime.Parse("1990-01-01"), Address = "sample address", ProfileImagePath = "~/Images/dr-grid-1.jpg" }; var result = userManager.Create(userToInsert, "Password@123"); if (result.Succeeded) { userManager.AddToRole(userToInsert.Id, "Doctor"); var department = context.Departments.SingleOrDefault(d => d.Name == "Cardiology"); var doctorDepartment = new DoctorDepartment { DepartmentId = department.DepartmentId, DoctorUserId = userToInsert.Id }; context.DoctorDepartments.AddOrUpdate(doctorDepartment); context.SaveChanges(); } } if (!(context.Users.Any(u => u.UserName == "*****@*****.**"))) { var userToInsert = new ApplicationUser { UserName = "******", FullName = "John Doe", Gender = "Male", DateOfBirth = DateTime.Parse("1990-01-01"), Address = "sample address", Mobile = "01300111222", Email = "*****@*****.**", ProfileImagePath = "~/Images/dr-grid-1.jpg" }; var result = userManager.Create(userToInsert, "Password@123"); if (result.Succeeded) { userManager.AddToRole(userToInsert.Id, "Doctor"); var department = context.Departments.SingleOrDefault(d => d.Name == "ENT"); var doctorDepartment = new DoctorDepartment { DepartmentId = department.DepartmentId, DoctorUserId = userToInsert.Id }; context.DoctorDepartments.AddOrUpdate(doctorDepartment); context.SaveChanges(); } } if (!(context.Users.Any(u => u.UserName == "*****@*****.**"))) { var userToInsert = new ApplicationUser { UserName = "******", FullName = "John Doe", Mobile = "01300111222", Gender = "Male", DateOfBirth = DateTime.Parse("1990-01-01"), Address = "sample address", Email = "*****@*****.**", ProfileImagePath = "~/Images/dr-grid-1.jpg" }; var result = userManager.Create(userToInsert, "Password@123"); if (result.Succeeded) { userManager.AddToRole(userToInsert.Id, "Doctor"); var department = context.Departments.SingleOrDefault(d => d.Name == "Eye Care"); var doctorDepartment = new DoctorDepartment { DepartmentId = department.DepartmentId, DoctorUserId = userToInsert.Id }; context.DoctorDepartments.AddOrUpdate(doctorDepartment); context.SaveChanges(); } } if (!(context.Users.Any(u => u.UserName == "*****@*****.**"))) { var userToInsert = new ApplicationUser { UserName = "******", FullName = "John Doe", Gender = "Male", DateOfBirth = DateTime.Parse("1990-01-01"), Address = "sample address", Mobile = "01300111222", Email = "*****@*****.**", ProfileImagePath = "~/Images/dr-grid-1.jpg" }; var result = userManager.Create(userToInsert, "Password@123"); if (result.Succeeded) { userManager.AddToRole(userToInsert.Id, "Doctor"); var department = context.Departments.SingleOrDefault(d => d.Name == "Diabetes Care"); var doctorDepartment = new DoctorDepartment { DepartmentId = department.DepartmentId, DoctorUserId = userToInsert.Id }; context.DoctorDepartments.AddOrUpdate(doctorDepartment); context.SaveChanges(); } } if (!(context.Users.Any(u => u.UserName == "*****@*****.**"))) { var userToInsert = new ApplicationUser { UserName = "******", FullName = "John Doe", Mobile = "01300111222", Gender = "Male", DateOfBirth = DateTime.Parse("1990-01-01"), Address = "sample address", Email = "*****@*****.**", ProfileImagePath = "~/Images/dr-grid-1.jpg" }; var result = userManager.Create(userToInsert, "Password@123"); if (result.Succeeded) { userManager.AddToRole(userToInsert.Id, "Doctor"); var department = context.Departments.SingleOrDefault(d => d.Name == "Orthopedics"); var doctorDepartment = new DoctorDepartment { DepartmentId = department.DepartmentId, DoctorUserId = userToInsert.Id }; context.DoctorDepartments.AddOrUpdate(doctorDepartment); context.SaveChanges(); } } if (!(context.Users.Any(u => u.UserName == "*****@*****.**"))) { var userToInsert = new ApplicationUser { UserName = "******", FullName = "John Doe", Mobile = "01300111222", Gender = "Male", DateOfBirth = DateTime.Parse("1990-01-01"), Address = "sample address", Email = "*****@*****.**", ProfileImagePath = "~/Images/dr-grid-1.jpg" }; var result = userManager.Create(userToInsert, "Password@123"); if (result.Succeeded) { userManager.AddToRole(userToInsert.Id, "Doctor"); var department = context.Departments.SingleOrDefault(d => d.Name == "Pulmology"); var doctorDepartment = new DoctorDepartment { DepartmentId = department.DepartmentId, DoctorUserId = userToInsert.Id }; context.DoctorDepartments.AddOrUpdate(doctorDepartment); context.SaveChanges(); } } if (!(context.Users.Any(u => u.UserName == "*****@*****.**"))) { var userToInsert = new ApplicationUser { UserName = "******", FullName = "John Doe", Mobile = "01300111222", Gender = "Male", DateOfBirth = DateTime.Parse("1990-01-01"), Address = "sample address", Email = "*****@*****.**", ProfileImagePath = "~/Images/dr-grid-1.jpg" }; var result = userManager.Create(userToInsert, "Password@123"); if (result.Succeeded) { userManager.AddToRole(userToInsert.Id, "Doctor"); var department = context.Departments.SingleOrDefault(d => d.Name == "Child Care"); var doctorDepartment = new DoctorDepartment { DepartmentId = department.DepartmentId, DoctorUserId = userToInsert.Id }; context.DoctorDepartments.AddOrUpdate(doctorDepartment); context.SaveChanges(); } } // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. E.g. // // context.People.AddOrUpdate( // p => p.FullName, // new Person { FullName = "Andrew Peters" }, // new Person { FullName = "Brice Lambson" }, // new Person { FullName = "Rowan Miller" } // ); // }