public ActionResult Create(Patient user)
 {
     try
     {
         Role role = db.Roles.FirstOrDefault(r => r.RoleName == "User");
         user.Roles = new List<Role>() { role };
         user.CreatedDate = DateTime.UtcNow;
         user.ProfilePicture = "photo.jpg";
         user.IsActive = true;
         int getLastId = db.Users.Max(item => item.UserId);
         user.UserId = getLastId;
         user.Password = accBusiness.GeneratePassword();
         db.Patients.Add(user);
         db.SaveChanges();
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                 eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                     ve.PropertyName, ve.ErrorMessage);
             }
         }
     }
     Thread emailBackground = new Thread(delegate()
     {
         var subject = "Tạo tài khoản bệnh nhân";
         var body = "<html>" +
                           "<body>" +
                               "<h2>Hệ thống đã tạo cho bạn một tài khoản với các thông tin: </h2>" +
                               "<p>Mật khẩu: " + user.Password + "</p>" +
                           "</body>" +
                       "</html>";
         accBusiness.SendMail(user.Email, subject, body);
     });
     emailBackground.IsBackground = true;
     emailBackground.Start();
     return RedirectToAction("Index");
 }
        public ActionResult CreatePatient(Patient patient)
        {
            try
            {
                Role role = _db.Roles.FirstOrDefault(r => r.RoleName == "User");
                patient.Roles = new List<Role>();
                patient.Roles.Add(role);
                patient.CreatedDate = DateTime.UtcNow;
                patient.ProfilePicture = "photo.jpg";
                var email = Request.Params["Email"];
                string emailPatient = Convert.ToString(email);
                patient.Email = emailPatient;
                var first = Request.Params["FirstName"];
                string firstname = Convert.ToString(first);
                patient.FirstName = firstname;
                var last = Request.Params["LastName"];
                string lastname = Convert.ToString(last);
                patient.LastName = lastname;
                var ethnicity = Request.Params["Ethnicity"];
                string ethnicityP = Convert.ToString(ethnicity);
                patient.Ethnicity = ethnicityP;
                var nationality = Request.Params["Nationality"];
                string nationalityP = Convert.ToString(nationality);
                patient.Nationality = nationalityP;
                patient.IsActive = true;
                patient.Password = accBusiness.GeneratePassword();
                _db.Users.Add(patient);
                _db.SaveChanges();
                int getLastId = _db.Users.Max(item => item.UserId);
                PersonalHealthRecord personal = new PersonalHealthRecord();
                personal.PatientId = getLastId;
                var height = Request.Params["height"];
                if (height == "")
                {
                    personal.Height = 0;
                }
                else
                {
                    double heightPatient = double.Parse(height);
                    personal.Height = heightPatient;
                }

                var weight = Request.Params["weight"];
                if (weight == "")
                {
                    personal.Weight = 0;
                }
                else
                {
                    double weightPatient = double.Parse(weight);
                    personal.Height = weightPatient;
                }

                var eye = Request.Params["eye"];
                string eyeColor = eye.ToString();

                var hair = Request.Params["hair"];
                string hairColor = hair.ToString();

                var blood = Request.Params["blood"];
                string bloodType = blood.ToString();

                var alcoholWeek = Request.Params["alcoholweek"];
                if (alcoholWeek == "")
                {
                    personal.AlcoholPerWeek = 0;
                }
                else
                {
                    double alcoholPerWeek = double.Parse(alcoholWeek);
                    personal.AlcoholPerWeek = alcoholPerWeek;
                }

                var alcoholYear = Request.Params["alcoholyear"];
                if (alcoholYear == "")
                {
                    personal.AlcoholNumOfYear = 0;
                }
                else
                {
                    int alcoholNumberOfYear = Convert.ToInt32(alcoholYear);
                    personal.AlcoholNumOfYear = alcoholNumberOfYear;
                }

                var smokeYear = Request.Params["smokeyear"];
                if (smokeYear == "")
                {
                    personal.SmokePackPerWeek = 0;
                }
                else
                {
                    int smokeNumberOfYear = Convert.ToInt32(smokeYear);
                    personal.SmokeNumOfYear = smokeNumberOfYear;
                }

                var smokeWeek = Request.Params["smokeweek"];
                if (smokeWeek == "")
                {
                    personal.SmokePackPerWeek = 0;
                }
                else
                {
                    double smokePerWeek = double.Parse(smokeWeek);
                    personal.SmokePackPerWeek = smokePerWeek;
                }

                var sport = Request.Params["sport"];
                string sportName = sport.ToString();

                var sportWeek = Request.Params["sportweek"];
                if (sportWeek == "")
                {
                    personal.SportPerWeek = 0;
                }
                else
                {
                    int sportPerWeek = Convert.ToInt32(sportWeek);
                    personal.SportPerWeek = sportPerWeek;
                }

                var exercise = Request.Params["exercise"];
                string exerciseType = exercise.ToString();

                var exerciseWeek = Request.Params["exerciseweek"];
                if (exerciseWeek == "")
                {
                    personal.ExercisePerWeek = 0;
                }
                else
                {
                    int exercisePerWeek = Convert.ToInt32(exerciseWeek);
                    personal.ExercisePerWeek = exercisePerWeek;
                }
                _db.PersonalHealthRecords.Add(personal);
                _db.SaveChanges();
                Patient newPatient = new Patient();
                newPatient.UserId = getLastId;
                _db.Patients.Add(newPatient);
                _db.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                        eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                            ve.PropertyName, ve.ErrorMessage);
                    }
                }
            }
            // Create thread to send mail (background)
            Thread emailBackground = new Thread(delegate()
            {
                var subject = "Tạo tài khoản bệnh nhân";
                var body = "<html>" +
                                  "<body>" +
                                      "<h2>Hệ thống đã tạo cho bạn một tài khoản với các thông tin: </h2>" +
                                      "<p>Mật khẩu: " + patient.Password + "</p>" +
                                  "</body>" +
                              "</html>";
                accBusiness.SendMail(patient.Email, subject, body);
            });
            emailBackground.IsBackground = true;
            emailBackground.Start();
            return RedirectToAction("Index");
        }
        public ActionResult EditPatient(Patient patient, HttpPostedFileBase file)
        {
            if (file == null)
            {
                var filename = Request.Params["profile"];
                string profile = Convert.ToString(filename);
                patient.ProfilePicture = profile;
            }
            else if (file != null)
            {
                var fileName = Path.GetFileName(file.FileName);
                var path = HttpContext.Server.MapPath("~/Content/Image/ProfilePicture/" + fileName);
                var dbPath = string.Format("/Content/Image/ProfilePicture/" + fileName);
                file.SaveAs(path);
                patient.ProfilePicture = fileName;
            }

            var first = Request.Params["FirstName"];
            string firstname = Convert.ToString(first);
            patient.FirstName = firstname;
            var last = Request.Params["LastName"];
            string lastname = Convert.ToString(last);
            patient.LastName = lastname;
            var ethnicity = Request.Params["Ethnicity"];
            string ethnicityP = Convert.ToString(ethnicity);
            patient.Ethnicity = ethnicityP;
            var nationality = Request.Params["Nationality"];
            string nationalityP = Convert.ToString(nationality);
            patient.Nationality = nationalityP;
            patient.IsActive = true;
            _db.Entry(patient).State = EntityState.Modified;
            _db.SaveChanges();

            var id = Request.Params["patientid"];
            int patientid = Convert.ToInt32(id);

            var height = Request.Params["height"];
            double heightPatient = double.Parse(height);

            var weight = Request.Params["weight"];
            double weightPatient = double.Parse(weight);

            var eye = Request.Params["eye"];
            string eyeColor = eye.ToString();

            var hair = Request.Params["hair"];
            string hairColor = hair.ToString();

            var blood = Request.Params["blood"];
            string bloodType = blood.ToString();

            var alcoholWeek = Request.Params["alcoholweek"];
            double alcoholPerWeek = double.Parse(alcoholWeek);

            var alcoholYear = Request.Params["alcoholyear"];
            int alcoholNumberOfYear = Convert.ToInt32(alcoholYear);

            var smokeYear = Request.Params["smokeyear"];
            int smokeNumberOfYear = Convert.ToInt32(smokeYear);

            var smokeWeek = Request.Params["smokeweek"];
            double smokePerWeek = double.Parse(smokeWeek);

            var sport = Request.Params["sport"];
            string sportName = sport.ToString();

            var sportWeek = Request.Params["sportweek"];
            int sportPerWeek = Convert.ToInt32(sportWeek);

            var exercise = Request.Params["exercise"];
            string exerciseType = exercise.ToString();

            var exerciseWeek = Request.Params["exerciseweek"];
            int exercisePerWeek = Convert.ToInt32(exerciseWeek);
            PersonalHealthRecord personal = new PersonalHealthRecord()
            {
                PatientId = patientid,
                Height = heightPatient,
                Weight = weightPatient,
                EyeColor = eyeColor,
                HairColor = hairColor,
                BloodType = bloodType,
                AlcoholPerWeek = alcoholPerWeek,
                AlcoholNumOfYear = alcoholNumberOfYear,
                IsBeer = true,
                SmokeNumOfYear = smokeNumberOfYear,
                SmokePackPerWeek = smokePerWeek,
                SportName = sportName,
                SportPerWeek = sportPerWeek,
                ExerciseType = exerciseType,
                ExercisePerWeek = exercisePerWeek
            };
            _db.Entry(personal).State = EntityState.Modified;
            _db.SaveChanges();
            return RedirectToAction("Index");
        }
 public ActionResult Edit(Patient user, HttpPostedFileBase file)
 {
     if (ModelState.IsValid)
     {
         if (file == null)
         {
             var filename = Request.Params["profile"];
             string profile = Convert.ToString(filename);
             user.ProfilePicture = profile;
         }
         else if (file != null)
         {
             var fileName = Path.GetFileName(file.FileName);
             var path = HttpContext.Server.MapPath("~/Content/Image/ProfilePicture/" + fileName);
             var dbPath = string.Format("/Content/Image/ProfilePicture/" + fileName);
             file.SaveAs(path);
             user.ProfilePicture = fileName;
         }
         //user.Roles.Add(role);
         user.IsActive = true;
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return PartialView("_Edit", user);
 }
コード例 #5
0
        public void SendMessageTo(string toUsername, string message)
        {
            business = new ConversationBusiness(_db);
            Debug.WriteLine(toUsername + " " + message);
            var id = Context.ConnectionId;
            var fromUserDetail = ConnectedUsers.Where(x => x.ConnectionId == id).FirstOrDefault();
            var fromUser = _db.Users.Where(x => x.Username.Equals(fromUserDetail.Username)).FirstOrDefault();
            var toUser = _db.Users.Where(x => x.Username.Equals(toUsername)).FirstOrDefault();
            var toUserDetail = ConnectedUsers.Where(x => x.Username.Equals(toUsername)).FirstOrDefault();

            var doctor = _db.Doctors.Where(u => u.Username.Equals(fromUser.Username)).FirstOrDefault();
            var patient = new Patient();
            if (doctor == null)
            {
                doctor = _db.Doctors.Where(u => u.Username.Equals(toUser.Username)).FirstOrDefault();
                patient = _db.Patients.Where(u => u.Username.Equals(fromUser.Username)).FirstOrDefault();
            }
            else
            {
                patient = _db.Patients.Where(u => u.Username.Equals(toUser.Username)).FirstOrDefault();
            }
            if (doctor != null && patient != null)
            {
                //Store in database
                Conversation conversation = _db.Conversations.Where(
                    x => (x.PatientId == patient.UserId && x.DoctorId == doctor.UserId))
                .OrderByDescending(x => x.DateConsulted).FirstOrDefault();

                Debug.WriteLine("DoctorId = " + toUser.UserId, "  PatientId = " + fromUser.UserId);
                if (conversation == null)
                {
                    conversation = new Conversation
                    {
                        DoctorId = toUser.UserId,
                        PatientId = fromUser.UserId,
                        DateConsulted = DateTime.Now,
                        LatestTimeFromDoctor = DateTime.Now,
                        LatestTimeFromPatient = DateTime.Now
                    };
                    _db.Conversations.Add(conversation);
                }

                conversation.LatestTimeFromPatient = DateTime.Now;
                conversation.LatestContentFromPatient = message;
                conversation.IsRead = false;

                ConversationDetail conversationDetail = new ConversationDetail
                {
                    UserId = fromUser.UserId,
                    Content = message,
                    Conversation = conversation,
                    CreatedDate = DateTime.Now,
                    IsRead = false
                };

                MessageDetail messageDetail = new MessageDetail
                {
                    Content = message,
                    Username = fromUser.Username,
                    CreatedDate = String.Format("{0:H:mm:ss}", DateTime.Now),
                    IsRead = false
                };

                _db.ConversationDetails.Add(conversationDetail);
                _db.SaveChanges();

                //Notify Receiver
                var receivers = ConnectedUsers.Where(x => x.Username == toUsername).ToList();
                if (receivers != null)
                {
                    foreach (var receiver in receivers)
                    {
                        receiver.CountMessageUnRead = business.CountMessageUnRead(toUser);
                        if (receiver != null && receiver.ConnectionId != null)
                            Clients.Client(receiver.ConnectionId).messageReceived(fromUserDetail, toUserDetail, messageDetail);
                    }
                }

                //Notify Caller
                Clients.Caller.messageReceived(fromUserDetail, toUserDetail, messageDetail);
            }
        }
コード例 #6
0
        public void GetMessageList(string username)
        {
            business = new ConversationBusiness(_db);
            var id = Context.ConnectionId;
            var fromUserDetail = ConnectedUsers.Where(x => x.ConnectionId == id).FirstOrDefault();
            var fromUser = _db.Users.Where(x => x.Username.Equals(fromUserDetail.Username)).FirstOrDefault();
            var toUser = _db.Users.Where(x => x.Username.Equals(username)).FirstOrDefault();
            var toUserDetail = ConnectedUsers.Where(x => x.Username.Equals(username)).FirstOrDefault();

            //Check if toUserDetail is not online yet
            if (toUserDetail == null)
            {
                toUserDetail = new UserDetail
                {
                    FullName = toUser.FullName,
                    Username = toUser.Username,
                    IsOnline = false,
                    ProfilePicture = toUser.ProfilePicture
                };
            }

            var doctor = _db.Doctors.Where(u => u.Username.Equals(fromUser.Username)).FirstOrDefault();
            var patient = new Patient();
            if (doctor == null)
            {
                doctor = _db.Doctors.Where(u => u.Username.Equals(toUser.Username)).FirstOrDefault();
                patient = _db.Patients.Where(u => u.Username.Equals(fromUser.Username)).FirstOrDefault();
            }
            else
            {
                patient = _db.Patients.Where(u => u.Username.Equals(toUser.Username)).FirstOrDefault();
            }
            if (doctor != null && patient != null)
            {
                Debug.WriteLine("Patient: " + patient.Username + "  " + "Doctor: " + doctor.Username);
                DoctorDetail doctorDetail = Doctors.Where(u => u.Username.Equals(doctor.Username)).FirstOrDefault();
                var newestConversation = _db.Conversations.Where(
                    con => (con.PatientId == patient.UserId) && (con.DoctorId == doctor.UserId))
                    .OrderByDescending(con => con.DateConsulted).FirstOrDefault();

                if (newestConversation != null)
                {
                    var conversationDetails = _db.ConversationDetails.Where(cd => cd.Conversation.ConversationId == newestConversation.ConversationId).
                    OrderBy(cd => cd.CreatedDate).ToList();

                    //Convert conversationDetails to MessageDetails
                    var messageDetails = new List<MessageDetail>();
                    foreach (var conversationDetail in conversationDetails)
                    {
                        String date = (DateTime.Now.Subtract(conversationDetail.CreatedDate).Days) > 1 ?
                            String.Format("{0:HH:mm:ss}", conversationDetail.CreatedDate) :
                            String.Format("{0:dd/mm/yyyy HH:mm:ss}", conversationDetail.CreatedDate);
                        MessageDetail messageDetail = new MessageDetail
                        {
                            Content = conversationDetail.Content,
                            CreatedDate = date,
                            Username = conversationDetail.User.Username,
                            IsRead = conversationDetail.IsRead
                        };
                        messageDetails.Add(messageDetail);
                    }
                    Debug.WriteLine(messageDetails.Count);
                    if (fromUserDetail.Username.Equals(doctor.Username))
                    {
                        business.MarkConversationAsRead(newestConversation);
                        this.ConnectDoctor(doctor.Username);
                    }
                    Clients.Caller.onGetMessageList(fromUserDetail, toUserDetail, messageDetails);
                }
                else
                {
                    Clients.Caller.onGetMessageList(fromUserDetail, toUserDetail, "");
                }
            }
        }
コード例 #7
0
        public void SendMessageTo(string toEmail, string message)
        {
            business = new ConversationBusiness(_db);
            var id = Context.ConnectionId;
            var fromUserDetail = ConnectedUsers.Where(x => x.ConnectionId == id).FirstOrDefault();
            var fromUser = _db.Users.Where(x => x.Email.Equals(fromUserDetail.Email)).FirstOrDefault();
            var toUser = _db.Users.Where(x => x.Email.Equals(toEmail)).FirstOrDefault();
            var toUserDetail = ConnectedUsers.Where(x => x.Email.Equals(toEmail)).FirstOrDefault();

            var doctor = _db.Doctors.Where(u => u.Email.Equals(fromUser.Email)).FirstOrDefault();
            var patient = new Patient();
            if (doctor == null)
            {
                doctor = _db.Doctors.Where(u => u.Email.Equals(toUser.Email)).FirstOrDefault();
                patient = _db.Patients.Where(u => u.Email.Equals(fromUser.Email)).FirstOrDefault();
            }
            else
            {
                patient = _db.Patients.Where(u => u.Email.Equals(toUser.Email)).FirstOrDefault();
            }
            if (doctor != null && patient != null)
            {
                //Check if toUserDetail is not online yet
                if (toUserDetail == null)
                {
                    toUserDetail = helper.ConvertUserToUserDetail(toUser);
                }

                helper.SyncUserDetailWhenSendMessage(fromUserDetail, toEmail, message, ConnectedUsers);

                MessageDetail messageDetail = helper.SaveMessageToDatabase(fromUser, patient, doctor, message);

                //Notify Receiver
                var receivers = ConnectedUsers.Where(x => x.Email == toEmail).ToList();
                foreach (var receiver in receivers)
                {
                    if (receiver != null && receiver.ConnectionId != null)
                    {
                        receiver.CountMessageUnRead = business.CountMessageUnRead(toUser);
                        Clients.Client(receiver.ConnectionId).messageReceived(fromUserDetail, toUserDetail, messageDetail);

                        //If receiver is docter
                        if (toEmail.Equals(doctor.Email)) {
                            var userDetailList = helper.GetLastestConversationList(receiver.Email, ConnectedUsers);
                            receiver.ConversationList = userDetailList;
                            Clients.Client(receiver.ConnectionId).onGetConversationList(receiver.ConversationList);
                        }
                    }
                }

                //Notify Caller
                Clients.Caller.messageReceived(fromUserDetail, toUserDetail, messageDetail);
            }
        }
コード例 #8
0
        public void GetLastestChatMessage(string toEmail)
        {
            var id = Context.ConnectionId;
            var fromUserDetail = ConnectedUsers.Where(x => x.ConnectionId == id).FirstOrDefault();
            var fromUser = _db.Users.Where(x => x.Email.Equals(fromUserDetail.Email)).FirstOrDefault();
            var toUser = _db.Users.Where(x => x.Email.Equals(toEmail)).FirstOrDefault();
            var toUserDetail = ConnectedUsers.Where(x => x.Email.Equals(toEmail)).FirstOrDefault();

            var doctor = _db.Doctors.Where(u => u.Email.Equals(fromUser.Email)).FirstOrDefault();
            var patient = new Patient();
            if (doctor == null)
            {
                doctor = _db.Doctors.Where(u => u.Email.Equals(toUser.Email)).FirstOrDefault();
                patient = _db.Patients.Where(u => u.Email.Equals(fromUser.Email)).FirstOrDefault();
            }
            else
            {
                patient = _db.Patients.Where(u => u.Email.Equals(toUser.Email)).FirstOrDefault();
            }

            if (doctor != null && patient != null)
            {
                var conversation = _db.Conversations.Where(x => x.DoctorId == doctor.UserId && x.PatientId == patient.UserId).FirstOrDefault();
                var lastestConversationDetail = _db.ConversationDetails.Where(x => x.ConversationId == conversation.ConversationId).OrderByDescending(x => x.CreatedDate).FirstOrDefault();

                MessageDetail messageDetail = new MessageDetail
                {
                    Content = lastestConversationDetail.Content,
                    Attachment = lastestConversationDetail.Attachment,
                    CreatedDate = String.Format("{0:dd/MM/yyyy HH:mm:ss}", lastestConversationDetail.CreatedDate),
                    Email = lastestConversationDetail.User.Email,
                    IsRead = lastestConversationDetail.IsRead
                };

                //Check if toUserDetail is not online yet
                if (toUserDetail == null)
                {
                    toUserDetail = helper.ConvertUserToUserDetail(toUser);
                }

                //Notify Receiver
                var receiver = ConnectedUsers.Where(x => x.Email == toEmail).FirstOrDefault();

                if (receiver != null && receiver.ConnectionId != null)
                {
                    receiver.CountMessageUnRead = business.CountMessageUnRead(toUser);
                    Clients.Client(receiver.ConnectionId).messageReceived(fromUserDetail, toUserDetail, messageDetail);
                }

                //Notify Caller
                Clients.Caller.messageReceived(fromUserDetail, toUserDetail, messageDetail);
            }
        }
        public JsonResult Upload(string fromEmail, string toEmail)
        {
            for (int i = 0; i < Request.Files.Count; i++)
            {
                HttpPostedFileBase file = Request.Files[i]; //Uploaded file
                //Use the following properties to get file's name, size and MIMEType
                if (file != null)
                {
                    int fileSize = file.ContentLength;
                    string fileName = file.FileName;
                    string mimeType = file.ContentType;
                    System.IO.Stream fileContent = file.InputStream;
                    //To save file, use SaveAs method
                    file.SaveAs(Server.MapPath("~/Content/Upload/") + fileName); //File will be saved in application root
                    var fromUser = _db.Users.Where(x => x.Email.Equals(fromEmail)).FirstOrDefault();
                    var toUser = _db.Users.Where(x => x.Email.Equals(toEmail)).FirstOrDefault();
                    var doctor = _db.Doctors.Where(u => u.Email.Equals(fromUser.Email)).FirstOrDefault();
                    var patient = new Patient();
                    if (doctor == null)
                    {
                        doctor = _db.Doctors.Where(u => u.Email.Equals(toUser.Email)).FirstOrDefault();
                        patient = _db.Patients.Where(u => u.Email.Equals(fromUser.Email)).FirstOrDefault();
                    }
                    else
                    {
                        patient = _db.Patients.Where(u => u.Email.Equals(toUser.Email)).FirstOrDefault();
                    }

                    Conversation conversation = _db.Conversations.Where(x => (x.PatientId == patient.UserId && x.DoctorId == doctor.UserId)).FirstOrDefault();

                    if (conversation == null)
                    {
                        conversation = new Conversation
                        {
                            DoctorId = doctor.UserId,
                            PatientId = patient.UserId,
                            LatestTimeFromDoctor = DateTime.Now,
                            LatestTimeFromPatient = DateTime.Now
                        };
                        _db.Conversations.Add(conversation);
                    }

                    if (fromUser.Email == patient.Email)
                    {
                        conversation.LatestTimeFromPatient = DateTime.Now;
                        conversation.LatestContentFromPatient = fileName;
                        conversation.IsDoctorRead = false;
                    }
                    else
                    {
                        conversation.LatestTimeFromDoctor = DateTime.Now;
                        conversation.LatestContentFromDoctor = fileName;
                        conversation.IsPatientRead = false;
                    }
                    String date = String.Format("{0:dd/MM/yyyy HH:mm:ss}", DateTime.Now);
                    IFormatProvider culture = new System.Globalization.CultureInfo("fr-FR", true);
                    ConversationDetail conversationDetail = new ConversationDetail
                    {
                        UserId = fromUser.UserId,
                        Attachment = fileName,
                        Conversation = conversation,
                        CreatedDate = DateTime.Parse(date, culture, System.Globalization.DateTimeStyles.AssumeLocal),
                        IsRead = false
                    };
                    _db.ConversationDetails.Add(conversationDetail);
                    _db.SaveChanges();
                }

            }
            return Json("Đã upload " + Request.Files.Count + " dữ liệu");
        }