public IHttpActionResult PostDoctorReg(DoctorReg doctorReg)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DoctorRegs.Add(doctorReg);
            string tmp = dc.temppassword();

            doctorReg.Password            = tmp;
            doctorReg.Emailconform        = 0;
            doctorReg.Logintime           = DateTime.Now;
            doctorReg.Logouttime          = DateTime.Now;
            doctorReg.temp_pasw_attempted = 0;
            db.SaveChanges();
            Guid activationCode = Guid.NewGuid();

            doctorReg.ActivationCode = activationCode.ToString();
            string s  = dc.SendActivationEmail(doctorReg);
            string s1 = dc.SendAdminEmail(doctorReg);

            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = doctorReg.id }, doctorReg));
        }
예제 #2
0
        public ActionResult ActivationMail(DoctorReg doctorsReg)
        {
            ViewBag.Message = "Invalid Activation code.";
            if (RouteData.Values["id"] != null)
            {
                Guid activationCode = new Guid(RouteData.Values["id"].ToString());

                var userActivation = db.DoctorRegs.Where(p => p.ActivationCode == activationCode.ToString() && p.Emailconform == 0).FirstOrDefault();
                if (userActivation != null)
                {
                    userActivation.Emailconform = 1;
                    db.DoctorRegs.Attach(userActivation);
                    db.Entry(userActivation).Property(x => x.Emailconform).IsModified = true;
                    db.SaveChanges();
                    return(RedirectToAction("../HTML/MailActivated.html"));

                    //db.UserActivation.Remove(userActivation);
                    //db.SaveChanges();
                    //ViewBag.Message = "Activation successful.";
                }
                else
                {
                    return(RedirectToAction("../HTML/AlreadyActivated.html"));
                }
            }

            return(View());
        }
        public IHttpActionResult PutDoctorReg(int id, DoctorReg doctorReg)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != doctorReg.id)
            {
                return(BadRequest());
            }

            db.Entry(doctorReg).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DoctorRegExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #4
0
 public ActionResult ConfirmPassword(DoctorReg model)
 {
     try
     {
         var user = _context.DOCTORTB.SingleOrDefault(
             u => u.Doctor_ID.Equals(model.Doctor_ID) &&
             u.Doctor_Password.Equals(model.Doctor_Password)
             );
         if (user != null)
         {
             ViewBag.DoctorName = TempData["SessionName"];
             TempData.Keep("SessionName");
             ViewBag.DoctorImg = TempData["SessionImg"];
             TempData.Keep("SessionImg");
             ViewBag.SID = TempData["Sessionid"];
             TempData.Keep("Sessionid");
             TempData.Keep("CountAppo");
             TempData.Keep("CountPat");
             TempData.Keep("CountReview");
             return(View("ChangePassword"));
         }
         else
         {
             return(RedirectToAction("Not"));
         }
     }
     catch (Exception e)
     {
         return(View(e));
     }
     // return RedirectToAction("../Home1/Index");
 }
예제 #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            DoctorReg doctorReg = db.DoctorRegs.Find(id);

            db.DoctorRegs.Remove(doctorReg);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #6
0
 public ActionResult Edit([Bind(Include = "id,Title,FirstName,MiddleName,LastName,Dob,Gender,NHSNo,PostCode,AddressLine1,AddressLine2,AddressLine3,City,State,Country,HomeNo,WorkNo,MobileNo,EmailID1,Email2,Age,ParentName,Relation,ParentAddress,ParentContactNo,NxKintName,NxtKinAddress,NxtKinContactNo,FileName,FilePath,ActivationCode,Password,Uniquecode,Emailconform,Status,Logintime,Logouttime,Deviceid,temp_pasw_attempted")] DoctorReg doctorReg)
 {
     if (ModelState.IsValid)
     {
         db.Entry(doctorReg).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(doctorReg));
 }
        public IHttpActionResult DeleteDoctorReg(int id)
        {
            DoctorReg doctorReg = db.DoctorRegs.Find(id);

            if (doctorReg == null)
            {
                return(NotFound());
            }

            db.DoctorRegs.Remove(doctorReg);
            db.SaveChanges();

            return(Ok(doctorReg));
        }
예제 #8
0
        // GET: DoctorRegs/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DoctorReg doctorReg = db.DoctorRegs.Find(id);

            if (doctorReg == null)
            {
                return(HttpNotFound());
            }
            return(View(doctorReg));
        }
예제 #9
0
        //public  string Decrypt(string cipherText)
        //{
        //    string EncryptionKey = "MAKV2SPBNI99212";
        //    byte[] cipherBytes = Convert.FromBase64String(cipherText);
        //    using (Aes encryptor = Aes.Create())
        //    {
        //        Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
        //        encryptor.Key = pdb.GetBytes(32);
        //        encryptor.IV = pdb.GetBytes(16);
        //        using (MemoryStream ms = new MemoryStream())
        //        {
        //            using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write))
        //            {
        //                cs.Write(cipherBytes, 0, cipherBytes.Length);
        //                cs.Close();
        //            }
        //            cipherText = Encoding.Unicode.GetString(ms.ToArray());
        //        }
        //    }
        //    return cipherText;
        //}
        public string SendActivationEmail(DoctorReg doctorReg)
        {
            db.DoctorRegs.Attach(doctorReg);

            db.Entry(doctorReg).Property(x => x.ActivationCode).IsModified = true;
            db.SaveChanges();

            try
            {
                using (MailMessage mm = new MailMessage("*****@*****.**", doctorReg.EmailID1))
                {
                    mm.Subject = "Account Activation";
                    string body = string.Empty;
                    //string body = "Hello " + doctorsReg.Fname + ",";
                    //body += "<br /><br />Please click the following link to activate your account";
                    //body += "<br /><a href = '" + string.Format("http://192.168.1.3/DoctorsRegs/ActivationMail/{0}", doctorsReg.ActivationCode) + "'>Click here to activate your account.</a>";
                    //body += "<br /><br />Thanks";
                    string name          = doctorReg.FirstName.ToString();
                    string activationurl = string.Format("http://192.168.1.3/ThinkdocotorApi/DoctorRegs/ActivationMail/{0}", doctorReg.ActivationCode);
                    string wmail         = doctorReg.EmailID1.ToString();
                    string temppasw      = Encrypt(doctorReg.Password.ToString());
                    string filePath      = Path.Combine(HttpRuntime.AppDomainAppPath, "MailHtml\\ConformationMail.html");
                    using (StreamReader reader = new StreamReader(filePath))
                    {
                        body = reader.ReadToEnd();
                    }
                    body          = body.Replace("{UserName}", name);
                    body          = body.Replace("{Url}", activationurl);
                    body          = body.Replace("{Usermail}", wmail);
                    body          = body.Replace("{Password}", temppasw);
                    mm.Body       = body;
                    mm.IsBodyHtml = true;
                    SmtpClient smtp = new SmtpClient();
                    smtp.Host      = "smtp.gmail.com";
                    smtp.EnableSsl = true;
                    NetworkCredential NetworkCred = new NetworkCredential("*****@*****.**", "prasannamca1107");
                    smtp.UseDefaultCredentials = true;
                    smtp.Credentials           = NetworkCred;
                    smtp.Port = 587;
                    smtp.Send(mm);
                }
                return("succ");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
예제 #10
0
        public IActionResult Login(DoctorReg doctorReg)
        {
            try
            {
                var user = _context.DOCTORTB.Where(u => u.Doctor_Email == doctorReg.Doctor_Email && u.Doctor_Password == doctorReg.Doctor_Password).FirstOrDefault();
                if (user != null)
                {
                    //HttpContext.Session.SetString("SessionName", user.Doctor_Name);
                    //ViewBag.DocName = HttpContext.Session.GetString("SessionName");

                    HttpContext.Session.SetInt32("SessionID", user.Doctor_ID);
                    ViewBag.SID = HttpContext.Session.GetInt32("SessionID");

                    HttpContext.Session.SetString("SessionImg", user.Doctor_Profile);
                    ViewBag.DoctorImg = HttpContext.Session.GetString("SessionImg");

                    //for edit data
                    HttpContext.Session.SetString("SessionPassword", user.Doctor_Password);
                    ViewBag.DoctorPassword = HttpContext.Session.GetString("SessionPassword");

                    HttpContext.Session.SetString("SessionName", user.Doctor_Name);
                    ViewBag.DoctorName = HttpContext.Session.GetString("SessionName");

                    TempData["Sessionid"]   = HttpContext.Session.GetInt32("SessionID");
                    TempData["SessionImg"]  = HttpContext.Session.GetString("SessionImg");
                    TempData["SessionName"] = HttpContext.Session.GetString("SessionName");

                    TempData.Keep("CountAppo");
                    TempData.Keep("CountPat");
                    TempData.Keep("CountReview");

                    //return View("../Home1/Index");
                    return(RedirectToAction("Index", "Home1"));
                    //return RedirectToAction("Create","DocClinic");
                }
                else
                {
                    return(RedirectToAction("LoginFail"));
                }
            }
            catch (Exception e)
            {
                return(View(e));
            }
        }
예제 #11
0
        public async Task <IActionResult> Edit(IFormFile fileobj, [Bind("Doctor_ID,Doctor_Name,Doctor_Email,Doctor_Gender,Doctor_Password,Doctor_Contact,Doctor_IsActive,Category_ID,Doctor_Degree,Doctor_Profile,Doctor_Experience,Doctor_Education")] DoctorReg doctorReg, string fname, int id)
        {
            var getimg = await _context.DOCTORTB.FindAsync(id);

            _context.DOCTORTB.Remove(getimg);
            fname = Path.Combine("../Medical/wwwroot", "Doctor_Image", getimg.Doctor_Profile);
            FileInfo fi = new FileInfo(fname);

            if (fi.Exists)
            {
                System.IO.File.Delete(fname);
                fi.Delete();
            }
            var imgext = Path.GetExtension(fileobj.FileName);

            if (imgext == ".jpg" || imgext == ".png")
            {
                var uploadimg = Path.Combine("../Medical/wwwroot", "Doctor_Image", fileobj.FileName);
                var stream    = new FileStream(uploadimg, FileMode.Create);

                await fileobj.CopyToAsync(stream);

                stream.Close();

                var Pass = HttpContext.Session.GetString("SessionPassword");
                //mi.Medicine_ID = 1;
                doctorReg.Doctor_Profile  = fileobj.FileName;
                doctorReg.Doctor_IsActive = false;
                doctorReg.Doctor_Password = Pass;
                _context.Update(doctorReg);
                await _context.SaveChangesAsync();
            }

            ViewBag.DoctorName = TempData["SessionName"];
            TempData.Keep("SessionName");
            ViewBag.DoctorImg = TempData["SessionImg"];
            TempData.Keep("SessionImg");
            ViewBag.SID = TempData["Sessionid"];
            TempData.Keep("Sessionid");
            TempData.Keep("CountAppo");
            TempData.Keep("CountPat");
            TempData.Keep("CountReview");
            return(RedirectToAction("Index", "Home1"));
        }
예제 #12
0
        public ActionResult ChangePassword(int id, DoctorReg model)
        {
            var item = _context.DOCTORTB.Where(x => x.Doctor_ID == model.Doctor_ID).First();

            item.Doctor_Password = model.Doctor_Password;
            //_context.Update(model);
            _context.SaveChanges();

            ViewBag.DoctorName = TempData["SessionName"];
            TempData.Keep("SessionName");
            ViewBag.DoctorImg = TempData["SessionImg"];
            TempData.Keep("SessionImg");
            ViewBag.SID = TempData["Sessionid"];
            TempData.Keep("Sessionid");
            TempData.Keep("CountAppo");
            TempData.Keep("CountPat");
            TempData.Keep("CountReview");
            return(RedirectToAction("PasswordChangeMsg"));
        }
예제 #13
0
        public string SendAdminEmail(DoctorReg doctorsReg)
        {
            try
            {
                using (MailMessage mm = new MailMessage("*****@*****.**", "*****@*****.**"))
                {
                    mm.Subject = "One Account Created..";
                    string body = string.Empty;
                    //string body = "Hello " + doctorsReg.Fname + ",";
                    //body += "<br /><br />Please click the following link to activate your account";
                    //body += "<br /><a href = '" + string.Format("http://192.168.1.3/DoctorsRegs/ActivationMail", doctorsReg.ActivationCode) + "'>Click here to activate your account.</a>";
                    //body += "<br /><br />Thanks";
                    string name     = doctorsReg.FirstName;
                    string deviceid = doctorsReg.Deviceid;
                    string filePath = Path.Combine(HttpRuntime.AppDomainAppPath, "MailHtml\\AdminKnowRegs.html");
                    using (StreamReader reader = new StreamReader(filePath))
                    {
                        body = reader.ReadToEnd();
                    }
                    body = body.Replace("{UserName}", name);
                    body = body.Replace("{DeviceId}", deviceid);

                    mm.Body       = body;
                    mm.IsBodyHtml = true;
                    SmtpClient smtp = new SmtpClient();
                    smtp.Host      = "smtp.gmail.com";
                    smtp.EnableSsl = true;
                    NetworkCredential NetworkCred = new NetworkCredential("*****@*****.**", "prasannamca1107");
                    smtp.UseDefaultCredentials = true;
                    smtp.Credentials           = NetworkCred;
                    smtp.Port = 587;
                    smtp.Send(mm);
                }
                return("succ");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
예제 #14
0
        public async Task <IActionResult> Create([Bind("Doctor_ID,Doctor_Name,Doctor_Email,Doctor_Gender,Doctor_Password,Doctor_Contact,Doctor_IsActive,Category_ID,Doctor_Degree,Doctor_Profile,Doctor_Experience,Doctor_Education")] DoctorReg doctorReg, IFormCollection formCollection, IFormFile fileobj)
        {
            loadCategory();
            var imgext = Path.GetExtension(fileobj.FileName);

            if (imgext == ".jpg" || imgext == ".png")
            {
                var uploadimg = Path.Combine("../Medical/wwwroot", "Doctor_Image", fileobj.FileName);
                var stream    = new FileStream(uploadimg, FileMode.Create);

                await fileobj.CopyToAsync(stream);

                stream.Close();

                //mi.Medicine_ID = 1;
                doctorReg.Doctor_Profile  = fileobj.FileName;
                doctorReg.Doctor_IsActive = false;

                await _context.DOCTORTB.AddAsync(doctorReg);

                await _context.SaveChangesAsync();

                ViewBag.DoctorName = TempData["SessionName"];
                TempData.Keep("SessionName");
                ViewBag.DoctorImg = TempData["SessionImg"];
                TempData.Keep("SessionImg");
                ViewBag.SID = TempData["Sessionid"];
                TempData.Keep("Sessionid");
                TempData.Keep("CountAppo");
                TempData.Keep("CountPat");
                TempData.Keep("CountReview");
                return(RedirectToAction("Login", "DoctorReg"));
            }



            return(View(doctorReg));
        }
예제 #15
0
        public ActionResult Create([Bind(Include = "id,Title,FirstName,MiddleName,LastName,Dob,Gender,NHSNo,PostCode,AddressLine1,AddressLine2,AddressLine3,City,State,Country,HomeNo,WorkNo,MobileNo,EmailID1,Email2,Age,ParentName,Relation,ParentAddress,ParentContactNo,NxKintName,NxtKinAddress,NxtKinContactNo,FileName,FilePath,ActivationCode,Password,Uniquecode,Emailconform,Status,Logintime,Logouttime,Deviceid,temp_pasw_attempted")] DoctorReg doctorReg)
        {
            if (ModelState.IsValid)
            {
                db.DoctorRegs.Add(doctorReg);
                string tmp      = temppassword();
                var    password = Encrypt(tmp);
                doctorReg.Password            = password;
                doctorReg.Emailconform        = 0;
                doctorReg.Logintime           = DateTime.Now;
                doctorReg.Logouttime          = DateTime.Now;
                doctorReg.temp_pasw_attempted = 0;
                db.SaveChanges();
                Guid activationCode = Guid.NewGuid();
                doctorReg.ActivationCode = activationCode.ToString();
                string s = SendActivationEmail(doctorReg);

                string s1 = SendAdminEmail(doctorReg);

                return(RedirectToAction("Index"));
            }

            return(View(doctorReg));
        }