Example #1
0
        public ActionResult EdittedDrProfile(DoctorCompoundModel accountInfo)
        {
            string username    = Session["username"].ToString();
            var    doctor      = smokeFreeDB.Doctor.Find(username);
            var    generalUser = smokeFreeDB.GeneralUser.Find(username);

            HttpPostedFileBase postedFile = Request.Files["ImageFile"];

            //If user uploads new profile picture
            if (postedFile.ContentLength > 0 && postedFile.ContentType.Contains("image"))
            {
                Stream       stream       = postedFile.InputStream;
                BinaryReader binaryReader = new BinaryReader(stream);
                byte[]       img          = binaryReader.ReadBytes((int)stream.Length);
                generalUser.profilePicture = img;
            }

            doctor.description  = accountInfo.Doctors.description;
            doctor.contactNo    = accountInfo.Doctors.contactNo;
            doctor.workLocation = accountInfo.Doctors.workLocation;
            smokeFreeDB.Configuration.ValidateOnSaveEnabled = false;
            smokeFreeDB.SaveChanges();

            return(RedirectToAction("DrProfile", new { viewUsername = username, page = 1 }));
        }
Example #2
0
        public ActionResult EditDrProfile()
        {
            DoctorCompoundModel docModel = new DoctorCompoundModel();

            if (Session["username"] == null)
            {
                return(RedirectToAction("SignIn", "Account"));
            }
            else
            {
                //Get username of current user logged in
                string username = Session["username"].ToString();

                //Get info of profile that is being viewed
                var generaldata = smokeFreeDB.GeneralUser.Where(x => x.userName.Equals(username));
                var docdata     = smokeFreeDB.Doctor.Where(x => x.userName.Equals(username));

                docModel.Doctors      = docdata.FirstOrDefault();
                docModel.GeneralUsers = generaldata.FirstOrDefault();

                ViewBag.username = username;
            }


            return(View(docModel));
        }
Example #3
0
        public ActionResult SignUpAsDoctor(DoctorCompoundModel accountInfo)
        {
            if (ModelState.IsValid)
            {
                var checkUsername = db.GeneralUser.FirstOrDefault(m => m.userName == accountInfo.GeneralUsers.userName);
                var checkEmail    = db.GeneralUser.FirstOrDefault(m => m.email == accountInfo.GeneralUsers.email);

                //Convert uploaded file to byte[]
                HttpPostedFileBase postedFile   = Request.Files["ImageFile"];
                Stream             stream       = postedFile.InputStream;
                BinaryReader       binaryReader = new BinaryReader(stream);
                byte[]             img          = binaryReader.ReadBytes((int)stream.Length);

                //Check if username & email already exists
                if (checkUsername == null)
                {
                    if (checkEmail == null)
                    {
                        //Set details
                        accountInfo.GeneralUsers.password       = GetMD5(accountInfo.GeneralUsers.password);
                        accountInfo.GeneralUsers.profilePicture = img;
                        accountInfo.Doctors.adminVerify         = false;
                        accountInfo.Doctors.description         = "";
                        accountInfo.Doctors.userName            = accountInfo.GeneralUsers.userName;

                        //Insert into database
                        db.Configuration.ValidateOnSaveEnabled = false;
                        db.GeneralUser.Add(accountInfo.GeneralUsers);
                        db.Doctor.Add(accountInfo.Doctors);
                        db.SaveChanges();
                        return(RedirectToAction("SignUpSuccessDoctor"));
                    }
                    else
                    {
                        ViewData["EmailExists"] = "Email already exists";
                    }
                }
                else
                {
                    ViewData["UsernameExists"] = "Username already exists";
                }
            }
            return(View("SignUpDoctor"));
        }