public ActionResult NewMsg(string text, string subject, int?msgTo)
        {
            Zinojumi message = new Zinojumi();
            Profils  user    = db.Accounts.Where(a => a.UserName == User.Identity.Name).FirstOrDefault();

            if (msgTo == null)
            {
                return(RedirectToAction("Index"));
            }
            if (text == "")
            {
                return(RedirectToAction("Index"));
            }
            message.msg        = text;
            message.msgFrom    = user;
            message.date       = DateTime.Now;
            message.dateString = message.date.ToString("d MMM HH:mm");
            message.subject    = subject;
            if (msgTo != null)
            {
                message.msgTo = db.Accounts.Find(msgTo);
            }
            db.Zinojumi.Add(message);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public ActionResult RegisterConfirm(Profils userData)
        {
            var userTest = db.Accounts.Where(a => a.UserName == userData.UserName).FirstOrDefault();

            if (userTest != null)
            {
                // users ar šādu username jau atrodas db
                ModelState.AddModelError("", "Lietotājs " + userData.UserName + " jau atrodas sistēmā!");
                ModelState.Remove("Password");
                return(View());
            }
            if (!string.IsNullOrEmpty(userData.Password))
            {
                if (!Regex.IsMatch(userData.Password, GetPasswordRegex()))
                {
                    ModelState.AddModelError("Password", "Parole neatbilst drošības prasībām!");
                }
            }
            var newProfile = new Profils()
            {
                UserName       = userData.UserName,
                Password       = HashSaltStore(userData.Password),
                RoleStart      = userData.RoleStart,
                Vards          = userData.Vards,
                Uzvards        = userData.Uzvards,
                AccountBlocked = false
            };

            db.Accounts.Add(newProfile);
            db.SaveChanges();
            ModelState.Clear();
            ViewBag.Message = "Lietotājs izveidots";
            return(View());
        }
        // GET: Message
        public ActionResult Index()
        {
            Profils user            = db.Accounts.Where(a => a.UserName == User.Identity.Name).FirstOrDefault();
            var     msgListReceived = db.Zinojumi.ToList()
                                      .Where(a => a.msgTo == user)
                                      .OrderByDescending(e => e.date);
            var msgListSent = db.Zinojumi.ToList()
                              .Where(a => a.msgFrom == user)
                              .OrderByDescending(e => e.date);
            var Messages = new ZinojumiView()
            {
                Received = msgListReceived,
                Sent     = msgListSent
            };

            if (user.RoleStart == "User")
            {   // Pacienti
                var recipentList = db.Accounts.ToList()
                                   .Where(a => a.RoleStart != "User" && a.ProfileID != user.ProfileID);
                Messages.AvailableRecipents = recipentList;
            }
            else
            {   // Ārsti/Admini
                //Var nosūtīt ziņu visiem admini/ārsti/pacienti
                var recipentList = db.Accounts.ToList()
                                   .Where(a => a.ProfileID != user.ProfileID);
                Messages.AvailableRecipents = recipentList;
            }
            return(View(Messages));
        }
Exemple #4
0
        public async Task <Profils> CreateProfile(Profils profils)
        {
            profils.Id = Guid.NewGuid();
            await _context.AddAsync(profils);

            await _context.SaveChangesAsync();

            return(profils);
        }
Exemple #5
0
        public async Task <ActionResult> CreateProfile([FromBody] Profils profils)
        {
            try
            {
                var result = await _profilService.CreateProfile(profils);

                return(Ok(result));
            }
            catch (Exception e)
            {
                var msg = $"Error When Create Profile. {e.Message}";
                return(StatusCode(500, msg));
            }
        }
Exemple #6
0
        public ActionResult ResetPasswordReqConfirm(Profils log, string returnurl)
        {
            try
            {
                var user     = db.Accounts.Where(a => a.UserName == log.UserName).FirstOrDefault();
                var password = "******" + DateTime.Now.ToString("ddmm");
                if (user.UserName != null)
                {
                    if (this.IsValidEmailAddress(user.UserName))
                    {
                        MailMessage mail = new MailMessage();

                        SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
                        smtpServer.EnableSsl             = true;
                        smtpServer.UseDefaultCredentials = false;
                        smtpServer.Credentials           = new NetworkCredential("*****@*****.**", "VS@2017AGKA");
                        smtpServer.Port = 587;

                        mail.From = new MailAddress("*****@*****.**");
                        mail.To.Add(user.UserName);
                        mail.Subject = "Paroles atjaunošana";
                        mail.Body    = ("Jūsu lietotājvārds: " + user.UserName + " un jaunā parole: " + password);

                        smtpServer.Send(mail);

                        user.Password       = HashSaltStore(password);
                        user.ToReset        = true;
                        user.AccountBlocked = false;
                        db.SaveChanges();
                        ModelState.AddModelError("", "Pieprasījums veiksmīgi nosūtīts");
                        return(View());
                    }
                    else
                    {
                        ModelState.AddModelError("", "Nav ievadīts korekts e-pasts");
                        return(View());
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Jūsu profils nav atrasts datubāzē");
                    return(View());
                }
            }
            catch
            {
                ModelState.AddModelError("", "Ir notikusi neparedzēta kļūda. Lūdzu mēģiniet vēlreiz!");
                return(View());
            }
        }
        private void CreateProfil()
        {
            var newProfil           = new ProfilViewModel();
            AddProfileDialog dialog = new AddProfileDialog
            {
                DataContext = newProfil,
                Owner       = Application.Current.MainWindow
            };
            var resDialog = dialog.ShowDialog();

            if (resDialog.HasValue && resDialog.Value)
            {
                newProfil.Command = new RelayCommand(o => SelectProfil((ProfilViewModel)o));
                Profils.Add(newProfil);
                SelectProfil(newProfil);
            }
        }
Exemple #8
0
        public ActionResult ResetPasswordConfirm(int?profileID, string newPassword, Profils profils)
        {
            if (profileID == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (newPassword != profils.Password)
            {
                return(View());
            }
            var account = db.Accounts.Find(profileID);

            account.Password        = HashSaltStore(newPassword);
            account.ToReset         = false;
            db.Entry(account).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("LoginAc"));
        }
Exemple #9
0
        public ActionResult SendMsgToPatient(int patientID, string MsgToPatient)
        {
            Profils user    = db.Accounts.Where(a => a.UserName == User.Identity.Name).FirstOrDefault();
            Profils patient = db.Accounts.Where(b => b.Patient.PacientaID == patientID).FirstOrDefault();
            var     message = new Zinojumi()
            {
                msg        = MsgToPatient,
                msgFrom    = user,
                date       = DateTime.Now,
                dateString = DateTime.Now.ToString("d MMM HH:mm"),
                msgTo      = patient
            };

            db.Zinojumi.Add(message);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
    // Start is called before the first frame update
    void Awake()
    {
        if (controller == null)
        {
            DontDestroyOnLoad(gameObject);
            controller = this;
        }
        else if (controller != this)
        {
            Destroy(gameObject);
        }

        Profils    = new Profils();
        Historique = new List <Historique>();
        Objets     = new List <Objets>();
        AssociationJustifications        = new List <Association_justification>();
        JustificationLienMateriel        = new List <JustificationMateriel>();
        CoherenceMaterielTechniqueOutils = new List <CoherenceMaterielTechniqueOutils>();



        Forme                 = new List <Item>();
        TailleObjet           = new List <Taille>();
        JustificationMateriel = new List <Item>();
        Outils                = new List <Item>();
        Technique             = new List <Item>();
        SousMateriaux         = new List <Item>();
        Materiaux             = new List <Materiaux>();
        Questions             = new List <Question>();

        load_CoherenceMateriel();
        load_JustificationMateriel();

        load_Profils();
        load_Objets();
        load_taille();
        load_Item(FORME_FILENAME, Forme);
        load_Item(JUSTIFICATION_FILENAME, JustificationMateriel);
        load_Item(OUTILS_FILENAME, Outils);
        load_Item(TECHNIQUE_FILENAME, Technique);
        load_Materiaux();

        load_currentState();
    }
Exemple #11
0
        public List <Profils> SelectNomProfil()
        {
            Profils profilName = null;

            try
            {
                this.ConnexionOpen();
                //Selection de l'historique
                string           sqlNomProfil      = "select lib_profil, id_profil from profil; ";
                SqliteCommand    commandaNomProfil = new SqliteCommand(sqlNomProfil, connexion);
                SqliteDataReader result            = commandaNomProfil.ExecuteReader();
                List <Profils>   profilNames       = new List <Profils>();
                //List<string> profilListExpensible;
                while (result.Read())
                {
                    //Historiques historiques = new Historiques();
                    profilName = new Profils();
                    String chaine  = result.GetString(0);
                    String chaine1 = result.GetString(1);
                    profilName.CreeProfil(chaine, chaine1);
                    profilNames.Add(profilName);
                }
                result.Close();
                return(profilNames);
            }
            //Retourne le message d'erreur SQL
            catch
            {
                List <Profils> profilNames = new List <Profils>();
                return(profilNames);
            }
            //Fermeture de la connexion
            finally
            {
                this.ConnexionClose();
            }
        }
 public ActionResult EditorReplyMsg(int?msgID, string mode, string subject, string text)
 {
     if (msgID == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     if (mode == "reply")
     {
         Profils user     = db.Accounts.Where(a => a.UserName == User.Identity.Name).FirstOrDefault();
         var     replyMsg = new Zinojumi()
         {
             msgTo   = db.Zinojumi.Find(msgID).msgFrom,
             subject = subject,
             msg     = text,
             msgFrom = user,
             date    = DateTime.Now
         };
         replyMsg.dateString = replyMsg.date.ToString("d MMM HH:mm");
         db.Zinojumi.Add(replyMsg);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else if (mode == "edit")
     {
         var msg = db.Zinojumi.Find(msgID);
         msg.msg             = text;
         msg.subject         = subject;
         db.Entry(msg).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
Exemple #13
0
        public ActionResult DeleteConfirmed(int?id)
        {
            try
            {
                var      finduser = db.Pacienti.Find(id);
                var      user     = db.Accounts.Where(a => a.Patient.PacientaID == finduser.PacientaID).FirstOrDefault();
                Pacients pacients = db.Pacienti.Find(id);
                Profils  profile  = db.Accounts.Find(user.ProfileID);

                var userMsgs = db.Zinojumi.Where(a => a.msgTo.Patient.PacientaID == finduser.PacientaID).ToList();
                foreach (var i in userMsgs)
                {
                    db.Zinojumi.Remove(i);
                }
                if (ModelState.IsValid)
                {
                    if (id == null)
                    {
                        return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                    }
                    if (pacients == null)
                    {
                        return(HttpNotFound());
                    }
                    db.Pacienti.Remove(pacients);
                    db.Accounts.Remove(profile);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                return(View(pacients));
            }
            catch
            {
                return(View());
            }
        }
Exemple #14
0
 public ActionResult LoginAc(Profils log, string returnUrl)
 {
     try
     {
         var user = db.Accounts.Where(a => a.UserName == log.UserName).FirstOrDefault();
         if (user.AccountBlocked == false)
         {
             if (HashSaltVerify(log.Password, user.Password))
             {
                 Session["loginclient"] = null;
                 if (user.ToReset)
                 {
                     return(RedirectToAction("ResetPassword", new { id = user.ProfileID }));
                 }
                 FormsAuthentication.SetAuthCookie(user.UserName, true);
                 if (user.RoleStart == "Employee" || user.RoleStart == "SuperAdmin")
                 {
                     return(RedirectToAction("Index"));
                 }
                 else
                 {
                     int returnID = user.Patient.PacientaID;
                     if (ModelState.IsValid)
                     {
                         return(RedirectToAction("PatientView", new { id = returnID }));
                     }
                 }
             }
             else
             {
                 if (Session["loginclient"] != null)
                 {
                     if (Convert.ToInt32(Session["loginclient"]) >= 3)
                     {
                         user.AccountBlocked = true;
                         db.SaveChanges();
                         ModelState.AddModelError("", "Jūsu konts ir bloķēts. Veiciet paroles atjaunināšanu");
                         Session["loginclient"] = null;
                         return(View());
                     }
                     else
                     {
                         Session["loginclient"] = Convert.ToInt32(Session["loginclient"]) + 1;
                         int atempt = 3 - Convert.ToInt32(Session["loginclient"]);
                         ModelState.AddModelError("", "Nepareiza parole. Atlikušie mēģinājumi: " + atempt);
                         return(View());
                     }
                 }
                 else
                 {
                     Session["loginclient"] = 1;
                     int atempt = 3 - Convert.ToInt32(Session["loginclient"]);
                     ModelState.AddModelError("", "Nepareiza parole. Atlikušie mēģinājumi: " + atempt);
                     return(View());
                 }
             }
         }
         ModelState.AddModelError("", "Jūsu konts ir bloķēts, veiciet paroles atjaunināšanu");
         return(View());
     }
     catch
     {
         ModelState.AddModelError("", "Nepareiza parole vai lietotājvārds");
         return(View());
     }
 }
Exemple #15
0
 public ActionResult Create(PacientsEditViewModel pacients)
 {
     try
     {
         var selectedRoom = db.Palatas.Find(pacients.SelectedRoomId);
         pacients.Patient.Palata = selectedRoom;
         var emailExist = db.Accounts.Where(a => a.UserName == pacients.Patient.Epasts).FirstOrDefault();
         if (emailExist != null)
         {
             pacients.RoomsFromWhichToSelect = availableRooms();
             ModelState.AddModelError("Patient.Epasts", "Pacients ar šādu e-pastu jau ir reģistrēts!");
             return(View(pacients));
         }
         var password      = "******" + DateTime.Now.ToString("ddmm");
         var insertprofile = new Profils
         {
             Patient        = pacients.Patient,
             UserName       = pacients.Patient.Epasts,
             Password       = HashSaltStore(password),
             Vards          = pacients.Patient.Vards,
             Uzvards        = pacients.Patient.Uzvards,
             RoleStart      = "User",
             ToReset        = true,
             AccountBlocked = false
         };
         if (selectedRoom.PalatasIetilpiba <= selectedRoom.Pacienti.Count())
         {
             // mēģinājums ievietot pilnā palātā vēlvienu pacientu
             pacients.RoomsFromWhichToSelect = availableRooms();
             ModelState.AddModelError("SelectedRoomId", "Palāta jau ir pilna!");
             return(View(pacients));
         }
         if (pacients.Patient.IerasanasDatums > DateTime.Now)
         {
             // mēģinājums ievietot nākotnes datumu
             pacients.RoomsFromWhichToSelect = availableRooms();
             ModelState.AddModelError("Patient.IerasanasDatums", "Ievietots nākotnes datums!");
             return(View(pacients));
         }
         if (pacients.Patient.IerasanasDatums < DateTime.Now.AddDays(-3))
         {
             // Mēģinājums ievietot pacientu palātā ar vairāk kā 3 dienu kavēšanos
             pacients.RoomsFromWhichToSelect = availableRooms();
             ModelState.AddModelError("Patient.IerasanasDatums", "Nokavētas vairāk kā 3 dienas!");
             return(View(pacients));
         }
         if (ModelState.IsValid)
         {
             db.Pacienti.Add(pacients.Patient);
             db.Accounts.Add(insertprofile);
             db.SaveChanges();
             TempData["AlertMessage"] = "Lietotājvārds: " + pacients.Patient.Epasts + " parole: " + password;
             return(RedirectToAction("Index"));
         }
         // validācija parāda kļūdas
         // Atgriežam view, bet tā kā GET metode netiek palaista šajā gadījumā un šai metodei netika nodots
         // pieejamo palātu saraksts pievienojam tās atkal šim objektam/entitijai (nezinu kā pareizi viņu sauc)
         pacients.RoomsFromWhichToSelect = availableRooms();
         return(View(pacients));
     }
     catch
     {
         var patientEditVm = new PacientsEditViewModel();
         patientEditVm.RoomsFromWhichToSelect = availableRooms();
         return(View(patientEditVm));
     }
 }