Esempio n. 1
0
        public JsonResult PasswordValidation(DoctorProfile doctor)
        {
            PezeshkPlusEntities db = new PezeshkPlusEntities();

            USP_SEL_Doctor_Result doctorLastInfo = (USP_SEL_Doctor_Result)Session["DoctorInfo"];

            List <int?> CheckPassword = db.USP_SEL_Password(doctorLastInfo.Email, doctor.Password).ToList();

            if (CheckPassword.Count == 0)
            {
                return(Json("پسورد وارد شده اشتباه است", JsonRequestBehavior.DenyGet));
            }
            return(Json(true, JsonRequestBehavior.DenyGet));
        }
Esempio n. 2
0
        public ActionResult ProfileSet(DoctorProfile doctorProfile)
        {
            try
            {
                USP_SEL_Doctor_Result doctorLastInfo = (USP_SEL_Doctor_Result)Session["DoctorInfo"];
                Session.Remove("DoctorInfo");

                PezeshkPlusEntities db = new PezeshkPlusEntities();

                if (doctorProfile.FirstName != doctorLastInfo.FirstName)
                {
                    db.USP_UPD_FirstName(doctorLastInfo.Email, doctorProfile.FirstName);
                }
                if (doctorProfile.LastName != doctorLastInfo.LastName)
                {
                    db.USP_UPD_LastName(doctorLastInfo.Email, doctorProfile.LastName);
                }

                if (doctorProfile.Password != null)
                {
                    if (doctorProfile.NewPassword != null)
                    {
                        db.USP_UPD_Password(doctorLastInfo.Email, doctorProfile.NewPassword);
                    }
                }

                if (doctorProfile.PhoneNumber != doctorLastInfo.PhoneNumber)
                {
                    List <int?> CheckPhoneNumber = db.USP_SEL_PhoneNumber(doctorProfile.PhoneNumber).ToList();
                    if (CheckPhoneNumber.Count == 1)
                    {
                        TempData["PhoneNumberError"] = "با این شماره موبایل قبلا ثبت نام شده است";
                        return(RedirectToAction("ProfileSet"));
                    }
                    db.USP_UPD_PhoneNumber(doctorLastInfo.Email, doctorProfile.PhoneNumber);
                }

                if (doctorProfile.ClinicPhone != doctorLastInfo.ClinicPhone)
                {
                    List <int?> CheckClinicPhone = db.USP_SEL_ClinicPhone(doctorProfile.ClinicPhone).ToList();
                    if (CheckClinicPhone.Count == 1)
                    {
                        TempData["ClinicPhoneError"] = "با این شماره تلفن مطب قبلا ثبت نام شده است";
                        return(RedirectToAction("ProfileSet"));
                    }
                    db.USP_UPD_ClinicPhone(doctorLastInfo.Email, doctorProfile.ClinicPhone);
                }

                if (doctorProfile.Province != doctorLastInfo.Province)
                {
                    db.USP_UPD_Province(doctorLastInfo.Email, doctorProfile.Province);
                }
                if (doctorProfile.City != doctorLastInfo.City)
                {
                    db.USP_UPD_City(doctorLastInfo.Email, doctorProfile.City);
                }
                if (doctorProfile.Address != doctorLastInfo.Address)
                {
                    db.USP_UPD_Address(doctorLastInfo.Email, doctorProfile.Address);
                }

                if (doctorProfile.NationalID != doctorLastInfo.NationalID)
                {
                    List <int?> CheckNationalID = db.USP_SEL_NationalID(doctorProfile.NationalID).ToList();
                    if (CheckNationalID.Count == 1)
                    {
                        TempData["NationalIDError"] = "با این کد ملی قبلا ثبت نام شده است";
                        return(RedirectToAction("ProfileSet"));
                    }
                    db.USP_UPD_NationalID(doctorLastInfo.Email, doctorProfile.NationalID);
                }

                if (doctorProfile.MedicalField != doctorLastInfo.MedicalField)
                {
                    List <int?> previousMedicalFieldID = db.USP_SEL_MedicalFieldID(doctorLastInfo.MedicalField).ToList();
                    List <int?> medicalFieldID         = db.USP_SEL_MedicalFieldID(doctorProfile.MedicalField).ToList();
                    db.USP_UPD_MedicalField(doctorLastInfo.Email, previousMedicalFieldID[0], medicalFieldID[0]);
                }
                if (doctorProfile.WorkTime != doctorLastInfo.WorkTime)
                {
                    db.USP_UPD_WorkTime(doctorLastInfo.Email, doctorProfile.WorkTime);
                }
                if (doctorProfile.Picture != null)
                {
                    if (Path.GetExtension(doctorProfile.Picture.FileName) != ".jpg" && Path.GetExtension(doctorProfile.Picture.FileName) != ".JPG" && Path.GetExtension(doctorProfile.Picture.FileName) != ".png" && Path.GetExtension(doctorProfile.Picture.FileName) != ".PNG" && Path.GetExtension(doctorProfile.Picture.FileName) != ".jpeg")
                    {
                        TempData["PictureError"] = "پسوند فایل ارسالی باید jpg یا jpeg یا png باشد";
                        return(RedirectToAction("ProfileSet"));
                    }
                    if (doctorProfile.Picture.ContentLength > 1 & doctorProfile.Picture.ContentLength < (5 * 1024 * 1024))
                    {
                        if (doctorLastInfo.PicAddress != null)
                        {
                            if (System.IO.File.Exists(doctorLastInfo.PicAddress))
                            {
                                System.IO.File.Delete(doctorLastInfo.PicAddress);
                            }
                        }
                        string extention   = Path.GetExtension(doctorProfile.Picture.FileName);
                        string guidNamePic = Guid.NewGuid().ToString();
                        string picAddress  = $"/Images/Doctors/{guidNamePic}{extention}";
                        doctorProfile.Picture.SaveAs(Server.MapPath("~" + $"{picAddress}"));
                        db.USP_UPD_PicAddress(doctorLastInfo.Email, picAddress);
                    }
                    else
                    {
                        TempData["PictureError"] = "سایز فایل عکس ارسال شده باید حداکثر 5 Mg باشد";
                        return(RedirectToAction("ProfileSet"));
                    }
                }
            }
            catch (Exception)
            {
                TempData["UpdateError"] = "خطایی در بروزرسانی اطلاعات رخ داد! لطفا مقادیر را چک کنید و دوباره تلاش کنید";
                return(RedirectToAction("ProfileSet"));
            }

            TempData["UpdateSuccessFully"] = "پروفایل شما با موفقیت بروزرسانی شد";
            return(RedirectToAction("ProfileSet"));
        }