コード例 #1
0
        public ActionResult Add(Doctor data)
        {
            try
            {
                using (_dbEntities)
                {
                    var isEmailExist = _dbEntities.Doctors.FirstOrDefault(s => s.Email == data.Email);
                    if (isEmailExist != null)
                    {
                        TempData["Error"] = "Email (" + data.Email + ") already exists in our system";
                        return(View(data));
                    }

                    var rnd  = new Random();
                    var pass = rnd.Next(0, 999999).ToString("D6");

                    data.RoleMasterId = (int)EnumList.Roles.Doctor;
                    data.Password     = pass;
                    data.CreatedDate  = DateTime.UtcNow;
                    data.IsActive     = true;
                    data.IsDelete     = false;
                    _dbEntities.Doctors.Add(data);
                    _dbEntities.SaveChanges();

                    //Send a mail to doctor
                    if (Request.Url != null)
                    {
                        var loginUrl = Url.Action("Index", "Admin", "", protocol: Request.Url.Scheme);

                        var replacements = new Dictionary <string, string>
                        {
                            { "#Password#", data.Password },
                            { "#login#", loginUrl },
                            { "#name#", data.FullName }
                        };

                        SendgridEmailHelpers.SendTempleteEmail((int)EnumList.EmailTemplete.DoctorRegistration, data.Email, data.FullName, replacements);
                    }

                    TempData["Success"] = "Doctor added successfully";

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
コード例 #2
0
        public ActionResult AcceptAppointment(long id)
        {
            try
            {
                using (_dbEntities)
                {
                    var data = _dbEntities.Appointments.Find(id);

                    if (data != null)
                    {
                        data.IsConfirm = true;
                        _dbEntities.Entry(data).State = System.Data.Entity.EntityState.Modified;
                        _dbEntities.SaveChanges();


                        //Send a mail to patient
                        if (Request.Url != null)
                        {
                            var replacements = new Dictionary <string, string>
                            {
                                { "#name#", data.Fullname },
                                { "#date#", data.AppointmentDate.ToString("dd-MM-yyyy HH:mm tt") },
                                { "#complaint#", data.Complaint }
                            };
                            SendgridEmailHelpers.SendTempleteEmail((int)EnumList.EmailTemplete.AppointmentAccept, data.Email, data.Fullname, replacements);
                        }

                        TempData["Success"] = "Appointment accepted successfully";
                    }
                    else
                    {
                        TempData["Error"] = "Appointment details not found";
                    }
                    return(RedirectToAction("Appointments"));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
コード例 #3
0
        public ActionResult ForgotPassword(LoginVm data)
        {
            try
            {
                using (_dbEntities)
                {
                    var user = _dbEntities.UserMasters.FirstOrDefault(s => s.Email == data.Email);

                    if (user != null)
                    {
                        if (Request.Url != null)
                        {
                            var loginUrl = Url.Action("Index", "Admin", "", protocol: Request.Url.Scheme);

                            var replacements = new Dictionary <string, string>
                            {
                                { "#Password#", user.Password },
                                { "#login#", loginUrl },
                                { "#name#", user.FullName }
                            };

                            SendgridEmailHelpers.SendTempleteEmail((int)EnumList.EmailTemplete.ForgotPassword, user.Email, user.FullName, replacements);
                        }

                        TempData["Success"] = "We have send the login information in your mailbox";
                        return(RedirectToAction("Index"));
                    }

                    TempData["Error"] = "This email is not found in our system";
                    return(View(data));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
コード例 #4
0
        public ActionResult ForgotPassword(LoginVm data, string userType)
        {
            try
            {
                using (_dbEntities)
                {
                    long   roleId;
                    string password, name;

                    if (userType == "2")
                    {
                        var doctor = _dbEntities.Doctors.FirstOrDefault(s => s.Email == data.Email);
                        if (doctor != null)
                        {
                            roleId   = doctor.RoleMasterId;
                            password = doctor.Password;
                            name     = doctor.FullName;
                        }
                        else
                        {
                            TempData["Error"] = "This email is not found in our system";
                            return(View(data));
                        }
                    }
                    else
                    {
                        var userMaster = _dbEntities.UserMasters.FirstOrDefault(s => s.Email == data.Email);
                        if (userMaster != null)
                        {
                            roleId   = userMaster.RoleMasterId;
                            password = userMaster.Password;
                            name     = userMaster.FullName;
                        }
                        else
                        {
                            TempData["Error"] = "This email is not found in our system";
                            return(View(data));
                        }
                    }

                    if (Request.Url != null)
                    {
                        var loginUrl = Url.Action("Authentication", roleId == (int)EnumList.Roles.Doctor ? "Doctor" : "Home", "", Request.Url.Scheme);

                        var replacements = new Dictionary <string, string>
                        {
                            { "#Password#", password },
                            { "#login#", loginUrl },
                            { "#name#", name }
                        };

                        SendgridEmailHelpers.SendTempleteEmail((int)EnumList.EmailTemplete.ForgotPassword, data.Email, name, replacements);
                    }

                    TempData["Success"] = "We have send the login information in your mailbox";
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }