コード例 #1
0
        public ReturnObject Get_Doctor(int id)
        {
            ReturnObject returnData = new ReturnObject();

            try
            {
                using (var db = new ddiarydbEntities())
                {
                    Doctor_Master doctor = db.Doctor_Master.Where(x => x.Doctor_id == id).FirstOrDefault();

                    returnData.message     = "Successfull";
                    returnData.status_code = Convert.ToInt32(Status.Sucess);
                    returnData.data1       = doctor;
                }
            }
            catch (Exception ex)
            {
                ErrHandler.WriteError(ex.Message, ex);
                returnData.data1       = ex;
                returnData.message     = "Oops something went wrong! ";
                returnData.status_code = Convert.ToInt32(Status.Failed);
            }

            return(returnData);
        }
コード例 #2
0
        public ActionResult Update_Status(int id, string status)
        {
            try
            {
                using (var db = new ddiarydbEntities())
                {
                    var appointment = (from s in db.Appointments
                                       where s.Id == id
                                       select s).FirstOrDefault();

                    if (appointment.DateStart > DateTime.Now)
                    {
                        appointment.Status      = status;
                        appointment.UpdatedDate = DateTime.Now;

                        db.Entry(appointment).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                }
            }
            catch
            {
            }
            return(RedirectToAction("Details"));
        }
コード例 #3
0
        public ReturnObject Get_DoctorBookedSlot(int id, DateTime DATE)
        {
            ReturnObject returnData = new ReturnObject();

            try
            {
                using (var db = new ddiarydbEntities())
                {
                    if (id > 0)
                    {
                        var bookedSlot = (from a in db.Appointments
                                          where a.DoctorId == id && (a.DateStart.Day == DATE.Day) && (a.DateStart.Month == DATE.Month) && (a.DateStart.Year == DATE.Year)
                                          select a.SessionId).ToList();

                        returnData.message     = "Successfull";
                        returnData.status_code = Convert.ToInt32(Status.Sucess);
                        returnData.data1       = bookedSlot;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrHandler.WriteError(ex.Message, ex);
                returnData.data1       = ex;
                returnData.message     = "Oops something went wrong! ";
                returnData.status_code = Convert.ToInt32(Status.Failed);
            }

            return(returnData);
        }
コード例 #4
0
        public ReturnObject FindDoctorsByString(string str = "")
        {
            ReturnObject returnData = new ReturnObject();

            try
            {
                using (var db = new ddiarydbEntities())
                {
                    var list     = new List <DoctorViewModel>();
                    var datalist = (from doc in db.Doctor_Master
                                    where doc.IsActive == true && doc.Doctor_name.ToLower().StartsWith(str.ToLower())
                                    select doc).ToList();

                    returnData.message     = "Successfull";
                    returnData.status_code = Convert.ToInt32(Status.Sucess);
                    returnData.data1       = datalist;
                }
            }
            catch (Exception ex)
            {
                ErrHandler.WriteError(ex.Message, ex);
                returnData.data1       = ex;
                returnData.message     = "Oops something went wrong! ";
                returnData.status_code = Convert.ToInt32(Status.Failed);
            }

            return(returnData);
        }
コード例 #5
0
        // GET: Patient/Create
        public ActionResult Edit(int id = 0)
        {
            if (id == 0)
            {
                if (Session["UserID"] != null)
                {
                    id = int.Parse(new EncryptDecrypt().Decrypt(Session["UserID"].ToString()));
                }
                else
                {
                    return(RedirectToAction("Login"));
                }
            }

            PatientViewModel obj = new PatientViewModel();

            using (var db = new ddiarydbEntities())
            {
                var patient = db.Patient_Master.Where(x => x.Patient_Id == id).FirstOrDefault();

                obj = new MappingService().Map <Patient_Master, PatientViewModel>(patient);

                //obj.Patient_photo = new PhotoPathTextService().IsAvailable(obj.Patient_photo, obj.Patient_name);
            }

            return(View(obj));
        }
コード例 #6
0
        // GET: Patient/Details/5
        public ActionResult Details(int id = 0, string status = "")
        {
            if (id == 0)
            {
                if (Session["UserID"] != null)
                {
                    id = int.Parse(new EncryptDecrypt().Decrypt(Session["UserID"].ToString()));
                }
                else
                {
                    //id = 31223;
                    return(RedirectToAction("Login"));
                }
            }

            PatientViewModel result = new PatientViewModel();

            using (var db = new ddiarydbEntities())
            {
                var patient = db.Patient_Master.Where(x => x.Patient_Id == id).FirstOrDefault();

                result = new MappingService().Map <Patient_Master, PatientViewModel>(patient);

                //result.Patient_photo = new PhotoPathTextService().IsAvailable(result.Patient_photo, result.Patient_name);

                var appointments = (from x in db.Appointments.AsEnumerable()
                                    where x.PatientId == id
                                    select x).OrderByDescending(x => x.DateStart).ToList <Appointment>();

                if (appointments != null)
                {
                    result.Appointments = new List <AppointmentViewModel>();
                    foreach (var item in appointments)
                    {
                        if (item.DateStart < DateTime.Now)
                        {
                            item.Status      = "Cancel";
                            item.UpdatedDate = DateTime.Now;

                            db.Entry(item).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                        }

                        var temp = new MappingService().Map <Appointment, AppointmentViewModel>(item);

                        var doctor = db.Doctor_Master.Where(x => x.Doctor_id == item.DoctorId).FirstOrDefault();
                        temp.Doctor = new MappingService().Map <Doctor_Master, DoctorViewModel>(doctor);
                        temp.Doctor.DoctorId_Encrypt = new EncryptDecrypt().Encrypt(doctor.Doctor_id.ToString());
                        temp.AppointmentId_Encrypt   = new EncryptDecrypt().Encrypt(temp.Id.ToString());

                        result.Appointments.Add(temp);
                    }
                }
            }

            return(View(result));
        }
コード例 #7
0
        public ActionResult Appointment(string id = "", int AppointmentId = 0, string status = "", string fromDate = "", string toDate = "", string msg = "")
        {
            int DoctorId = int.Parse(new EncryptDecrypt().Decrypt(id));

            DoctorAppointmentViewModel data = new DoctorAppointmentViewModel();

            AppointmentAPIController aController = new AppointmentAPIController();
            ReturnObject             ro          = new ReturnObject();

            using (var db = new ddiarydbEntities())
            {
                var doctor = db.Doctor_Master.Where(x => x.Doctor_id == DoctorId).FirstOrDefault();

                if (AppointmentId > 0)
                {
                    ro = aController.Update_Appointment(AppointmentId, status, msg);
                }

                var appointments = new List <Appointment>();

                ro = aController.Get_Appointments(0, DoctorId, fromDate, toDate);

                try
                {
                    appointments = (List <Appointment>)ro.data2;
                }
                catch (Exception)
                {
                    appointments = null;
                }

                if (doctor != null)
                {
                    data.Doctor = new DoctorViewModel().DoctorModel_to_ViewModel(doctor);

                    data.Appointments = new List <AppointmentViewModel>();
                    foreach (var item in appointments)
                    {
                        var temp = item.PatientName.Split(' ');
                        if (temp.Length > 1)
                        {
                            item.SessionId = temp[0].Substring(0, 1) + temp[1].Substring(0, 1);
                        }
                        else
                        {
                            item.SessionId = temp[0].Substring(0, 1);
                        }

                        data.Appointments.Add(new AppointmentViewModel().AppointmentModel_to_ViewModel(item));
                    }
                }
            }

            return(View(data));
        }
コード例 #8
0
        public ActionResult Booking(string doctorId, string appointmentId = "")
        {
            AppointmentViewModel appointment = new AppointmentViewModel();

            using (var db = new ddiarydbEntities())
            {
                if (appointmentId == "")
                {
                    int Doctor_Id = int.Parse(new EncryptDecrypt().Decrypt(doctorId));

                    var doctor = db.Doctor_Master.Where(x => x.Doctor_id == Doctor_Id).FirstOrDefault();

                    if (doctor != null)
                    {
                        appointment.Doctor = new DoctorViewModel().DoctorModel_to_ViewModel(doctor);
                    }
                    else
                    {
                        appointment.Doctor = null;
                    }

                    appointment.DateStart = DateTime.Now;
                    appointment.Relation  = "Self";
                }
                else
                {
                    appointment = new AppointmentViewModel();

                    appointment.Id = int.Parse(new EncryptDecrypt().Decrypt(appointmentId));

                    var dbAppointment = (from s in db.Appointments
                                         where s.Id == appointment.Id
                                         select s).FirstOrDefault();

                    appointment = new MappingService().Map <Appointment, AppointmentViewModel>(dbAppointment);

                    var doctor = db.Doctor_Master.Where(x => x.Doctor_id == dbAppointment.DoctorId).FirstOrDefault();

                    if (doctor != null)
                    {
                        appointment.Doctor = new DoctorViewModel().DoctorModel_to_ViewModel(doctor);
                    }
                    else
                    {
                        appointment.Doctor = null;
                    }
                }
            }

            return(View(appointment));
        }
コード例 #9
0
        public ActionResult DoctorProfile(string id)
        {
            int DoctorId = int.Parse(new EncryptDecrypt().Decrypt(id));

            DoctorViewModel data = new DoctorViewModel();

            using (var db = new ddiarydbEntities())
            {
                Doctor_Master doctor = db.Doctor_Master.Where(x => x.Doctor_id == DoctorId).FirstOrDefault();

                data = new DoctorViewModel().DoctorModel_to_ViewModel(doctor);
            }

            return(View(data));
        }
コード例 #10
0
        public ReturnObject FindPatientByMobile(string mobile = "")
        {
            ReturnObject returnData = new ReturnObject();

            if (mobile.Length == 10)
            {
                try
                {
                    using (var db = new ddiarydbEntities())
                    {
                        var patient = (from x in db.Patient_Master
                                       where x.Patient_contact == mobile
                                       select x).FirstOrDefault();

                        if (patient != null)
                        {
                            returnData.message     = "Successfull";
                            returnData.status_code = Convert.ToInt32(Status.Sucess);
                            returnData.data1       = new
                            {
                                patient.Patient_name,
                                patient.relation,
                                patient.Patient_contact
                            };
                        }
                        else
                        {
                            returnData.message     = "Mobile no is not found.";
                            returnData.status_code = Convert.ToInt32(Status.NotFound);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ErrHandler.WriteError(ex.Message, ex);
                    returnData.data1       = ex;
                    returnData.message     = "Oops something went wrong! ";
                    returnData.status_code = Convert.ToInt32(Status.Failed);
                }
            }
            else
            {
                returnData.message     = "Please enter valid mobile no.";
                returnData.status_code = Convert.ToInt32(Status.Failed);
            }
            return(returnData);
        }
コード例 #11
0
        public ReturnObject VerifyMobile(string mobile, string OTP)
        {
            ReturnObject returnData = new ReturnObject();

            try
            {
                using (ddiarydbEntities db = new ddiarydbEntities())
                {
                    var result = db.OTPVerifications.FirstOrDefault(x => x.MobileNo == mobile);
                    if (result != null)
                    {
                        if (result.OTP == OTP)
                        {
                            result.OTP             = "";
                            returnData.message     = "Successfull";
                            returnData.status_code = Convert.ToInt32(Status.Sucess);
                            returnData.data1       = result;
                        }
                        else
                        {
                            returnData.message     = "Please enter correct OTP.";
                            returnData.status_code = Convert.ToInt32(Status.Failed);
                        }
                    }
                    else
                    {
                        returnData.message     = "Oops something went wrong!";
                        returnData.status_code = Convert.ToInt32(Status.Failed);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrHandler.WriteError(ex.Message, ex);
                returnData.data1       = ex;
                returnData.message     = "Oops something went wrong! ";
                returnData.status_code = Convert.ToInt32(Status.Failed);
            }
            return(returnData);
        }
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });

            var identity = new ClaimsIdentity(context.Options.AuthenticationType);

            using (var db = new ddiarydbEntities())
            {
                var user = new usr();

                if (Regex.IsMatch(context.UserName, @"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}", RegexOptions.IgnoreCase))
                {
                    user = db.usrs.FirstOrDefault(x => x.Email == context.UserName);
                }
                else if (Regex.IsMatch(context.UserName, @"(\d*-)?\d{10}", RegexOptions.IgnoreCase))
                {
                    user = (from x in db.Doctor_Master
                            join u in db.usrs on x.User_id equals u.Id
                            where x.Doctor_contact == context.UserName
                            select u).FirstOrDefault();
                }
                else
                {
                    user = null;
                }

                if (user != null && user.passwd == context.Password)
                {
                    identity.AddClaim(new Claim(ClaimTypes.Role, "user"));
                    identity.AddClaim(new Claim("username", user.Email));
                    identity.AddClaim(new Claim(ClaimTypes.Name, user.Firstname + " " + user.Lastname));
                    context.Validated(identity);
                }
                else
                {
                    context.SetError("invalid_grant", "Provided username and password is incorrect");
                    return;
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// Purpose: Send OTP
        /// Created By: Vishal Chudasama on 25 Aug 2020
        /// </summary>
        /// <returns> OTP </returns>
        /// <param name="mobile"> Mobile No. </param>

        public JsonResult SendOTP(string mobile)
        {
            ReturnObject returnData = new ReturnObject();

            try
            {
                using (ddiarydbEntities db = new ddiarydbEntities())
                {
                    //var result = db.OTPVerifications.FirstOrDefault(x => x.MobileNo == mobile);
                    //if (result != null)
                    //{
                    //    //returnData.message = "Successfull";
                    //    //returnData.status_code = Convert.ToInt32(Status.Sucess);
                    //    //returnData.data1 = result.OTP;

                    //    returnData = new DoctorController().SendOTP("", mobile, result.OTP);
                    //}
                    //else
                    //{
                    string OTP = "";

                    Random r = new Random();

                    OTP = r.Next(1000, 9999).ToString();

                    returnData = new DoctorController().SendOTP("", mobile, OTP);
                    //}
                }
            }
            catch (Exception ex)
            {
                ErrHandler.WriteError(ex.Message, ex);
                returnData.data1       = ex;
                returnData.message     = "Oops something went wrong! ";
                returnData.status_code = Convert.ToInt32(Status.Failed);
            }

            return(Json(JsonConvert.SerializeObject(returnData), JsonRequestBehavior.AllowGet));
        }
コード例 #14
0
        public ActionResult Login(PatientLoginViewModel obj)
        {
            obj.dateTime = DateTime.Now;

            if (obj.OTP != null)
            {
                ReturnObject ro = new AppointmentAPIController().VerifyMobile(obj.MobileNo, obj.OTP);

                if (ro.status_code == 1)
                {
                    using (var db = new ddiarydbEntities())
                    {
                        var patient = db.Patient_Master.Where(x => x.Patient_contact == obj.MobileNo).FirstOrDefault();

                        if (patient != null)
                        {
                            Session["UserID"]   = new EncryptDecrypt().Encrypt(patient.Patient_Id.ToString());;
                            Session["UserName"] = patient.Patient_name.ToString();
                        }
                        else
                        {
                            Session["UserMobile"] = obj.MobileNo;
                        }
                    }

                    return(RedirectToAction("Details"));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Please Enter a valid OTP.");
                }
            }
            else
            {
                ModelState.AddModelError(string.Empty, "Please Enter a OTP.");
            }

            return(View(obj));
        }
コード例 #15
0
        public ReturnObject Get_DoctorsShift(int id = 0)
        {
            ReturnObject returnData = new ReturnObject();

            try
            {
                using (var db = new ddiarydbEntities())
                {
                    if (id > 0)
                    {
                        var docShifts = (from s in db.DoctorShifts
                                         where s.DoctorId == id
                                         select new
                        {
                            DoctorId = s.DoctorId,
                            ObTime = s.Slot,
                            MorningStart = s.MorningStart,
                            MorningEnd = s.MorningEnd,
                            AfternoorStart = s.AfternoonStart,
                            AfternoonEnd = s.AfternoonEnd
                        }).FirstOrDefault();

                        returnData.message     = "Successfull";
                        returnData.status_code = Convert.ToInt32(Status.Sucess);
                        returnData.data1       = docShifts;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrHandler.WriteError(ex.Message, ex);
                returnData.data1       = ex;
                returnData.message     = "Oops something went wrong! ";
                returnData.status_code = Convert.ToInt32(Status.Failed);
            }

            return(returnData);
        }
コード例 #16
0
        public ActionResult AppointmentDetails(string id)
        {
            int aid = int.Parse(new EncryptDecrypt().Decrypt(id));

            Appointment appointment = new Appointment();

            if (aid > 0)
            {
                using (var db = new ddiarydbEntities())
                {
                    appointment = (from s in db.Appointments
                                   where s.Id == aid
                                   select s).FirstOrDefault();


                    var doctor = db.Doctor_Master.Where(x => x.Doctor_id == appointment.DoctorId).FirstOrDefault();

                    TempData["DoctorName"] = doctor.Doctor_name;
                }
            }

            return(View(appointment));
        }
コード例 #17
0
        public ActionResult Booking(AppointmentViewModel appointment)
        {
            appointment.Status = "Pending";

            var startend = appointment.SessionId.Split('-');

            var date = Convert.ToDateTime(appointment.DateStart);

            var datetimeStart = date.ToShortDateString() + " " + startend[0];
            var datetimeEnd   = date.ToShortDateString() + " " + startend[1];

            appointment.DateStart = DateTime.Parse(datetimeStart);
            appointment.DateEnd   = DateTime.Parse(datetimeEnd);

            appointment.SessionId = appointment.DateStart.ToString("ddMMyyyyHHmm") + appointment.DateEnd.ToString("HHmm");

            try
            {
                using (var db = new ddiarydbEntities())
                {
                    Appointment obj = new MappingService().Map <AppointmentViewModel, Appointment>(appointment);
                    obj.DoctorId = int.Parse(new EncryptDecrypt().Decrypt(appointment.Doctor.DoctorId_Encrypt));

                    //db.Appointments.Add(obj);
                    //db.SaveChanges();
                    AppointmentAPIController aController  = new AppointmentAPIController();
                    ReturnObject             returnObject = new ReturnObject();

                    if (appointment.Id != 0)
                    {
                        returnObject = aController.Update_Appointment(obj);
                    }
                    else
                    {
                        returnObject = aController.Insert_Appointment(obj);
                    }

                    try
                    {
                        if (returnObject != null)
                        {
                            Appointment a = (Appointment)returnObject.data1;

                            var doctor = db.Doctor_Master.Where(x => x.Doctor_id == obj.DoctorId).FirstOrDefault();

                            TempData["DoctorName"] = doctor.Doctor_name;

                            string id = new EncryptDecrypt().Encrypt(a.Id.ToString());

                            return(Redirect("AppointmentDetails?id=" + id));
                        }

                        return(Redirect("Booking?id=" + appointment.Doctor.DoctorId_Encrypt));
                    }
                    catch (Exception ex)
                    {
                        ModelState.AddModelError(string.Empty, "Something Wrong.!");
                        return(View(appointment));
                    }
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, "Something Wrong.!");
                return(View(appointment));
            }
        }
コード例 #18
0
        public ReturnObject Get_Appointments(int id = 0, int DoctorId = 0, string fromDate = "", string toDate = "")
        {
            ReturnObject returnData = new ReturnObject();

            try
            {
                if (DoctorId > 0 && id == 0)
                {
                    using (var db = new ddiarydbEntities())
                    {
                        var doctor = db.Doctor_Master.Where(x => x.Doctor_id == DoctorId).FirstOrDefault();

                        var appointments = new List <Appointment>();

                        var FROMDATE = DateTime.Now;
                        var TODATE   = DateTime.Now;

                        if (fromDate == "" && toDate == "")
                        {
                            FROMDATE = DateTime.Now;
                            TODATE   = DateTime.Now;
                        }
                        else if (fromDate.Length > 0 && toDate == "")
                        {
                            FROMDATE = Convert.ToDateTime(fromDate);
                            TODATE   = Convert.ToDateTime(fromDate);
                        }
                        else
                        {
                            FROMDATE = Convert.ToDateTime(fromDate);
                            TODATE   = Convert.ToDateTime(toDate);
                        }

                        TimeSpan ssts = new TimeSpan(0, 0, 0);
                        FROMDATE = FROMDATE.Date + ssts;

                        TimeSpan ests = new TimeSpan(23, 59, 59);
                        TODATE = TODATE.Date + ests;


                        try
                        {
                            appointments = (from s in db.Appointments
                                            where s.DoctorId == DoctorId && s.DateStart >= FROMDATE && s.DateEnd <= TODATE
                                            select s).OrderByDescending(x => x.DateStart).ToList <Appointment>();
                        }
                        catch (Exception)
                        {
                            appointments = null;
                        }

                        returnData.message     = "Successfull";
                        returnData.status_code = Convert.ToInt32(Status.Sucess);
                        doctor.usr             = new usr();
                        returnData.data1       = doctor;
                        returnData.data2       = appointments;
                    }
                }
                else if (id > 0 && DoctorId == 0)
                {
                    using (var db = new ddiarydbEntities())
                    {
                        var appointment = (from s in db.Appointments
                                           where s.Id == id
                                           select s).FirstOrDefault();

                        returnData.message     = "Successfull";
                        returnData.status_code = Convert.ToInt32(Status.Sucess);
                        returnData.data1       = appointment;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrHandler.WriteError(ex.Message, ex);
                returnData.data1       = ex;
                returnData.message     = "Oops something went wrong! ";
                returnData.status_code = Convert.ToInt32(Status.Failed);
            }

            return(returnData);
        }
コード例 #19
0
        public ReturnObject Insert_Appointment(Appointment appointment)
        {
            ReturnObject returnData = new ReturnObject();

            try
            {
                using (var db = new ddiarydbEntities())
                {
                    if (db.Appointments.Any(x => x.DateStart == appointment.DateStart && x.DateEnd == appointment.DateEnd))
                    {
                        returnData.message     = "This time slot booked.";
                        returnData.status_code = Convert.ToInt32(Status.AlreadyExists);
                        returnData.data1       = appointment;

                        return(returnData);
                    }

                    appointment.CreatedDate = DateTime.Now;
                    appointment.UpdatedDate = DateTime.Now;

                    db.Appointments.Add(appointment);
                    db.SaveChanges();

                    Patient_Master patient = new Patient_Master();

                    patient = db.Patient_Master.Where(x => x.Patient_contact == appointment.PatientMobile).FirstOrDefault();

                    if (patient == null)
                    {
                        patient                 = new Patient_Master();
                        patient.Reg_Date        = DateTime.Now;
                        patient.Patient_name    = appointment.PatientName;
                        patient.Patient_contact = appointment.PatientMobile;
                        patient.relation        = appointment.Relation;
                        patient.IsActive        = false;
                        patient.User_Id         = db.Doctor_Master.Where(x => x.Doctor_id == appointment.DoctorId).Select(x => x.User_id).FirstOrDefault();

                        db.Patient_Master.Add(patient);
                        db.SaveChanges();
                    }

                    appointment.PatientId = patient.Patient_Id;

                    db.Entry(appointment).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    try
                    {
                        var doctor = db.Doctor_Master.Where(x => x.Doctor_id == appointment.DoctorId).FirstOrDefault();

                        var sms = "Your Appointment is Booked Successfully! Appointment booked with Dr." + doctor.Doctor_name + " on " +
                                  appointment.DateStart.ToString("dd MMM yyyy") + " " + appointment.DateStart.ToString("hh:mm tt") + " to " + appointment.DateEnd.ToString("hh:mm tt");

                        sms += appointment.Message != "" ? (" Reason: " + appointment.Message) : "";

                        SmsSend.Send(appointment.PatientMobile, sms);
                    }
                    catch (Exception)
                    { }

                    returnData.message     = "Successfull";
                    returnData.status_code = Convert.ToInt32(Status.Sucess);
                    returnData.data1       = appointment;
                }
            }
            catch (Exception ex)
            {
                ErrHandler.WriteError(ex.Message, ex);
                returnData.data1       = ex;
                returnData.message     = "Oops something went wrong! ";
                returnData.status_code = Convert.ToInt32(Status.Failed);
            }

            return(returnData);
        }
コード例 #20
0
        public ReturnObject Update_Appointment(int id, string status, string msg)
        {
            ReturnObject returnData = new ReturnObject();

            try
            {
                using (var db = new ddiarydbEntities())
                {
                    var appointment = (from s in db.Appointments
                                       where s.Id == id
                                       select s).FirstOrDefault();

                    if (appointment.DateStart > DateTime.Now)
                    {
                        appointment.Status = status;
                    }
                    else
                    {
                        appointment.Status = "Cancel";
                    }

                    //appointment.CreatedDate = DateTime.Now;
                    appointment.UpdatedDate = DateTime.Now;

                    db.Entry(appointment).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    var sms    = "";
                    var doctor = db.Doctor_Master.Where(x => x.Doctor_id == appointment.DoctorId).FirstOrDefault();

                    if (appointment.Status == "Accept")
                    {
                        sms = "Your Appointment is Accepted Successfully! Appointment booked with Dr." + doctor.Doctor_name + " on " +
                              appointment.DateStart.ToString("dd MMM yyyy") + " " + appointment.DateStart.ToString("hh:mm tt") + " to " + appointment.DateEnd.ToString("hh:mm tt");

                        Patient_Master patient = db.Patient_Master.Where(x => x.Patient_Id == appointment.PatientId).FirstOrDefault();

                        if (patient != null)
                        {
                            patient.IsActive = true;

                            db.Entry(patient).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                        }

                        DoctorPatient_Master doctorPatient = new DoctorPatient_Master();

                        doctorPatient = (from x in db.DoctorPatient_Master.AsEnumerable()
                                         where x.PatientId == appointment.PatientId && x.DoctorId == appointment.DoctorId
                                         select x).FirstOrDefault();

                        if (doctorPatient == null)
                        {
                            doctorPatient             = new DoctorPatient_Master();
                            doctorPatient.DoctorId    = appointment.DoctorId;
                            doctorPatient.PatientId   = appointment.PatientId;
                            doctorPatient.IsActive    = true;
                            doctorPatient.CreatedDate = DateTime.Now;
                            doctorPatient.UpdatedDate = DateTime.Now;

                            db.DoctorPatient_Master.Add(doctorPatient);
                            db.SaveChanges();
                        }
                        else
                        {
                            doctorPatient.UpdatedDate = DateTime.Now;

                            db.Entry(doctorPatient).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                        }
                    }
                    else if (appointment.Status == "Cancel")
                    {
                        sms = "Your Appointment booked on " +
                              appointment.DateStart.ToString("dd MMM yyyy") + " " + appointment.DateStart.ToString("hh:mm tt") + " to " + appointment.DateEnd.ToString("hh:mm tt") +
                              " is Canceled by Dr." + doctor.Doctor_name + ".";
                        sms = msg != "" ? (sms + " Reason: " + msg) : sms;
                    }

                    SmsSend.Send(appointment.PatientMobile, sms);


                    returnData.message     = "Successfull";
                    returnData.status_code = Convert.ToInt32(Status.Sucess);
                    returnData.data1       = appointment;
                }
            }
            catch (Exception ex)
            {
                ErrHandler.WriteError(ex.Message, ex);
                returnData.data1       = ex;
                returnData.message     = "Oops something went wrong! ";
                returnData.status_code = Convert.ToInt32(Status.Failed);
            }

            return(returnData);
        }
コード例 #21
0
        public ReturnObject Update_Appointment(Appointment appointment)
        {
            ReturnObject returnData = new ReturnObject();

            try
            {
                if (appointment.Id > 0)
                {
                    using (var db = new ddiarydbEntities())
                    {
                        var dbAppointment = db.Appointments.Where(x => x.Id == appointment.Id).FirstOrDefault();

                        if (db.Appointments.Any(x => x.Id != appointment.Id && x.DateStart == appointment.DateStart && x.DateEnd == appointment.DateEnd))
                        {
                            returnData.message     = "This time slot booked.";
                            returnData.status_code = Convert.ToInt32(Status.AlreadyExists);
                            returnData.data1       = appointment;

                            return(returnData);
                        }

                        dbAppointment.DateStart = appointment.DateStart;

                        dbAppointment.DateEnd = appointment.DateEnd;

                        dbAppointment.DoctorId = appointment.DoctorId;

                        dbAppointment.PatientId = appointment.PatientId;

                        dbAppointment.PatientName = appointment.PatientName;

                        dbAppointment.PatientMobile = appointment.PatientMobile;

                        dbAppointment.Relation = appointment.Relation;

                        dbAppointment.Status = appointment.Status;

                        dbAppointment.SessionId = appointment.DateStart.ToString("ddMMyyyyHHmm") + appointment.DateEnd.ToString("HHmm");

                        dbAppointment.UpdatedDate = DateTime.Now;

                        //dbAppointment.Message = appointment.Message;

                        db.Entry(dbAppointment).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();

                        try
                        {
                            var doctor = db.Doctor_Master.Where(x => x.Doctor_id == dbAppointment.DoctorId).FirstOrDefault();

                            var sms = "Your Appointment is Updated Successfully!" + Environment.NewLine +
                                      "Now, Appointment booked with Dr." + doctor.Doctor_name + " on " +
                                      dbAppointment.DateStart.ToString("dd MMM yyyy") + " " +
                                      dbAppointment.DateStart.ToString("hh:mm tt") + " to " + dbAppointment.DateEnd.ToString("hh:mm tt");

                            sms += appointment.Message != "" ? Environment.NewLine + (" Reason: " + appointment.Message) : "";

                            SmsSend.Send(appointment.PatientMobile, sms);
                        }
                        catch (Exception)
                        { }


                        returnData.message     = "Successfull";
                        returnData.status_code = Convert.ToInt32(Status.Sucess);
                        returnData.data1       = dbAppointment;
                    }
                }
                else
                {
                    returnData.message     = "Oops something went wrong! ";
                    returnData.status_code = Convert.ToInt32(Status.Failed);
                }
            }
            catch (Exception ex)
            {
                ErrHandler.WriteError(ex.Message, ex);
                returnData.data1       = ex;
                returnData.message     = "Oops something went wrong! ";
                returnData.status_code = Convert.ToInt32(Status.Failed);
            }

            return(returnData);
        }