Exemplo n.º 1
0
        private static bool Send(string phone, string content, out string result)
        {
            SmsSend.SmsSendMod info = new SmsSend.SmsSendMod();
            info.ServerUrl = Config.SmsConfig.ServerUrl;
            info.AppId     = Convert.ToInt32(Config.SmsConfig.AppId);
            info.AppKey    = Config.SmsConfig.AppKey;
            info.Phone     = phone;
            info.Content   = content;
            SmsSend ss = new SmsSend(info);

            return(ss.Send(out result));
        }
Exemplo n.º 2
0
        public IFormFile UploadFile(IFormFile model, int KorisnikId)
        {
            NastavnoOsoblje x = GetLogirani(KorisnikId);

            if (model != null)
            {
                x.NppFilePath = FileUploadDelete.Upload(_hostingEnvironment, model, "fileUpload", x.NppFilePath);
                SmsSend.Send(_SmsOptions, "38762738460",
                             "Nastavnik " + x.Ime + " " + x.Prezime + " je postavio dokument");
                _context.SaveChanges();
            }
            return(model);
        }
        /// <summary>
        /// 发送信息。
        /// </summary>
        /// <param name="sm"></param>
        /// <returns></returns>
        private string SendInfo(Send_Mod sm)
        {
            SmsSend.SmsSendMod info = new SmsSend.SmsSendMod();
            info.ServerUrl = Config.SmsConfig.ServerUrl;
            info.AppId     = Convert.ToInt32(Config.SmsConfig.AppId);
            info.AppKey    = Config.SmsConfig.AppKey;
            info.Phone     = sm.Phone;
            info.Content   = sm.Content;
            SmsSend ss = new SmsSend(info);
            string  msg;
            bool    IsOk = ss.Send(out msg);

            if (IsOk)
            {
                return("0");
            }
            else
            {
                return(msg);
            }
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }