public void CreateUserAndRoles() { DefyClinicContxet context = new DefyClinicContxet(); var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context)); var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context)); if (!roleManager.RoleExists("Admin")) { //create super admin role var role = new IdentityRole("Admin"); roleManager.Create(role); //create default user var user = new ApplicationUser(); user.UserName = "******"; user.Email = "*****@*****.**"; string pwd = "Admin@2019"; var newuser = userManager.Create(user, pwd); if (newuser.Succeeded) { userManager.AddToRole(user.Id, "Admin"); } } }
public ActionResult Edit([Bind(Include = "App_Id,P_Details,App_Status,App_Date,Dep,App_Time,Reason,isFree,TimeId")] Booking booking) { var result = DateTime.Compare(DateTime.Now, booking.AppDate); var errorMessage = ""; var repository = new DefyClinicRepository(); var contxet = new DefyClinicContxet(); //Appointment newTime = db.Appointments.Find(appointment.TimeId); //Appointment newDate = db.Appointments.Find(appointment.BookDate); var sTime = db.GetBookings().Where(p => p.TimeId == booking.TimeId).Select(p => p.TimeId).FirstOrDefault(); var sDate = db.GetBookings().Where(p => p.AppDate == booking.AppDate).Select(p => p.AppDate).FirstOrDefault(); var userId = ""; // ViewBag.App_Time = new SelectList(d.GetSlots().Where(X => X.Date.ToString() == id), "Id", "A_Slot"); ViewBag.App_Time = new SelectList(repository.GetSlots(), "BS_Id", "StartTime"); ViewData["App_Date"] = new SelectList(repository.GetSlots(), "Id", "Date"); var pNo = contxet.Staffs.Single(x => x.EmpEmail == userId).EmpNo; var pTitle = contxet.Staffs.Single(x => x.EmpEmail == userId).Title; var pName = contxet.Staffs.Single(x => x.EmpEmail == userId).EmpName; var pSurname = contxet.Staffs.Single(x => x.EmpEmail == userId).EmpSurname; var pGender = contxet.Staffs.Single(x => x.EmpEmail == userId).Gender; var pMobile = contxet.Staffs.Single(x => x.EmpEmail == userId).EmpTel; var pId = contxet.Staffs.Single(x => x.EmpEmail == userId).ID_Pass; var dep = contxet.Staffs.Single(x => x.EmpEmail == userId).Department.D_Name; ViewBag.P_Name = $"{pTitle} {pName} {pSurname}"; ViewBag.P_Gender = pGender; ViewBag.P_No = pNo; ViewBag.P_Mobiel = pMobile; ViewBag.P_ID = pId; ViewBag.Dep = dep; if (ModelState.IsValid) { var b = new Booking { PatientDetails = HttpContext.User.Identity.Name, AppDate = booking.AppDate, TimeId = booking.TimeId, AppStatus = "Not Yet Confirmed", AppId = booking.AppId, AppTime = booking.AppTime, Reason = booking.Reason, IsFree = true }; db.Edit(booking); return(RedirectToAction("Index")); } return(View(booking)); }
// GET: Bookings/Create public ActionResult Create(string Emp) { var d = new DefyClinicRepository(); var contxet = new DefyClinicContxet(); ViewData["App_Date"] = d.GetSlots().Where(w => w.Status) .AsEnumerable() .Select(i => new SelectListItem { Value = i.Date.ToShortDateString(), Text = i.Date.ToShortDateString() }); // ViewBag.App_Time = new SelectList(d.GetSlots().Where(X => X.Status == true), "Id", "A_Slot"); ViewBag.App_Time = d.GetSlots().Where(w => w.Status) .AsEnumerable() .Select(i => new SelectListItem { Value = i.A_Slot.ToShortTimeString(), Text = i.A_Slot.ToShortTimeString() }); // ViewBag.App_Time = d.GetSlots().Where(X => X.Status == true).SingleOrDefault().A_Slot.ToShortTimeString(); // ViewData["App_Date"] = new SelectList(d.GetSlots().Where(X => X.Status == true), "Id", "Date"); // ViewData["App_Date"] = d.GetSlots().Where(X => X.Status == true).SingleOrDefault().Date.ToShortDateString(); // ViewBag.App_Time = new SelectList(db.BookingSlots.Where(X => X.Date.ToString() == id), "BS_Id", "StartTime"); var userId = Emp ?? HttpContext.User.Identity.Name; var pNo = contxet.Staffs.Single(x => x.EmpEmail == userId).EmpNo; var pTitle = contxet.Staffs.Single(x => x.EmpEmail == userId).Title; var pName = contxet.Staffs.Single(x => x.EmpEmail == userId).EmpName; var pSurname = contxet.Staffs.Single(x => x.EmpEmail == userId).EmpSurname; var pGender = contxet.Staffs.Single(x => x.EmpEmail == userId).Gender; var pMobile = contxet.Staffs.Single(x => x.EmpEmail == userId).EmpTel; var pId = contxet.Staffs.Single(x => x.EmpEmail == userId).ID_Pass; var dep = contxet.Staffs.Single(x => x.EmpEmail == userId).Department.D_Name; ViewBag.P_Name = $"{pTitle} {pName} {pSurname}"; ViewBag.P_Gender = pGender; ViewBag.P_No = pNo; ViewBag.P_Mobiel = pMobile; ViewBag.P_ID = pId; ViewBag.Dep = dep; return(View()); }
public async Task <ActionResult> Register(RegisterViewModel model) { DefyClinicContxet db = new DefyClinicContxet(); if (db.Staffs.Any(X => X.EmpEmail == model.Email)) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { 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", "Home")); } AddErrors(result); } } else { ModelState.AddModelError("", "Make sure you used your DEFY employement email"); //ViewBag.Error = "Make sure you used your DEFY employemnt email"; } // If we got this far, something failed, redisplay form return(View(model)); }
// GET: Bookings/Edit/5 public ActionResult Edit(int?id) { var book = new Booking(); var userId = book.PatientDetails; var repository = new DefyClinicRepository(); var contxet = new DefyClinicContxet(); var pNo = contxet.Staffs.Single(x => x.EmpEmail == userId).EmpNo; var pTitle = contxet.Staffs.Single(x => x.EmpEmail == userId).Title; var pName = contxet.Staffs.Single(x => x.EmpEmail == userId).EmpName; var pSurname = contxet.Staffs.Single(x => x.EmpEmail == userId).EmpSurname; var pGender = contxet.Staffs.Single(x => x.EmpEmail == userId).Gender; var pMobile = contxet.Staffs.Single(x => x.EmpEmail == userId).EmpTel; var pId = contxet.Staffs.Single(x => x.EmpEmail == userId).ID_Pass; var dep = contxet.Staffs.Single(x => x.EmpEmail == userId).Department.D_Name; ViewBag.P_Name = $"{pTitle} {pName} {pSurname}"; ViewBag.P_Gender = pGender; ViewBag.P_No = pNo; ViewBag.P_Mobiel = pMobile; ViewBag.P_ID = pId; ViewBag.Dep = dep; ViewBag.App_Time = new SelectList(repository.GetSlots(), "BS_Id", "StartTime"); ViewData["App_Date"] = new SelectList(repository.GetSlots(), "Id", "Date"); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var booking = db.FindById(Convert.ToInt32(id)); if (booking == null) { return(HttpNotFound()); } return(View(booking)); }