Beispiel #1
0
 //adauga un utilizator
 public bool adaugaUtiliz(int id,string nume,string prenume,string email,string telefon,int rol, string user,string parola)
 {
     ResearchersEntities4 context = new ResearchersEntities4();
     if (cauta(id)) return false;
     Utilizator u = new Utilizator(id, user, parola, rol);
     context.Utilizator.Add(u);
     if (rol == 1)
     {
         Student s = new Student(id, nume, prenume, telefon, email);
         context.Student.Add(s);
         context.SaveChanges();
         return true;
     }
     else if (rol == 2)
     {
         Profesor p = new Profesor(id, nume, prenume);
         context.Profesor.Add(p);
         context.SaveChanges();
         return true;
     }
     else if (rol == 3)
     {
         Asistent a = new Asistent(id, nume, prenume);
         context.Asistent.Add(a);
         context.SaveChanges();
         return true;
     }
     return false;
 }
Beispiel #2
0
        // GET: Login/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Utilizator utilizator = db.Utilizator.Find(id);

            if (utilizator == null)
            {
                return(HttpNotFound());
            }
            return(View(utilizator));
        }
Beispiel #3
0
        private void ButtonConectare_Click(object sender, EventArgs e)
        {
            if (textBoxUtilizatorEmail.Text == "" || textBoxParola.Text == "")
            {
                if (textBoxUtilizatorEmail.Text == "")
                {
                    pictureBoxEroareUtilizatorSauEmail.Visible = true;
                    bunifuToolTip1.SetToolTip(pictureBoxEroareUtilizatorSauEmail, "Nu ai introdus numele de utilizator sau e-mail-ul");
                }
                if (textBoxParola.Text == "")
                {
                    pictureBoxEroareParolaAutentificare.Visible = true;
                    bunifuToolTip1.SetToolTip(pictureBoxEroareParolaAutentificare, "Nu ai introdus parola");
                }
            }
            else
            {
                Utilizator u = new Utilizator
                {
                    UserName = textBoxUtilizatorEmail.Text,
                    Email    = textBoxUtilizatorEmail.Text,
                    Parola   = textBoxParola.Text
                };

                DataTable dt = u.VerificareUtilizator(u);

                if (dt.Rows.Count > 0 && (textBoxUtilizatorEmail.Text == dt.Rows[0][0].ToString() || textBoxUtilizatorEmail.Text == dt.Rows[0][1].ToString()))
                {
                    utilizator = textBoxUtilizatorEmail.Text;
                    parola     = textBoxParola.Text;

                    if (dt.Rows[0][2].ToString() == "0")
                    {
                        u.ActivateDezactivareUtilizator(u, 1);
                    }

                    rol = Convert.ToInt32(dt.Rows[0][3]);

                    labelProverb.Text = Proverbe();
                    panelLoading.BringToFront();
                    timerLogin.Start();
                }
                else
                {
                    pictureBoxEroareParolaAutentificare.Visible = false;
                    pictureBoxEroareUtilizatorSauEmail.Visible  = true;
                    bunifuToolTip1.SetToolTip(pictureBoxEroareUtilizatorSauEmail, "Utilizatorul nu există sau ai introdus incorect");
                }
            }
        }
Beispiel #4
0
        //[AuthorizeToken]
        public ActionResult Index()
        {
            string        conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            Utilizator    u      = (Utilizator)Session["CURENT_USER"];
            DashboardJson dj     = new DashboardJson(Convert.ToInt32(u.ID), Convert.ToInt32(Session["ID_SOCIETATE"]), conStr);

            /*
             * DosareRepository dr = new DosareRepository(Convert.ToInt32(u.ID), conStr);
             * dj.DOSARE_TOTAL = Convert.ToInt32(dr.CountAll().Result);
             * dj.DOSARE_FROM_LAST_LOGIN = Convert.ToInt32(dr.CountFromLastLogin().Result);
             * dj.MESAJE_NOI = 0;
             */
            return(PartialView("_Dashboard", dj));
        }
Beispiel #5
0
        private void adaugareUtilizator(object sender, EventArgs e)
        {
            string username           = vAdministrator.GetTextBoxUsername().Text;
            string password           = vAdministrator.GetTextBoxPassword().Text;
            int    indexTipUtilizator = vAdministrator.GetComboBoxTipUtilizator().SelectedIndex;

            if (username.Length > 0 && password.Length > 0)
            {
                if (model.GetPersistentaUtilizator().CautaUtilizator(username) != null)
                {
                    MessageBox.Show("Exista deja un utilizator cu username-ul \"" + username + "\"");
                }
                else
                {
                    if (indexTipUtilizator == 0)
                    {
                        Utilizator utilizator = new Utilizator(username, password, "angajat");
                        if (model.GetPersistentaUtilizator().AdaugareUtilizator(utilizator))
                        {
                            MessageBox.Show("Adaugare incheiata cu succes!");
                            model.SetTipOperatie("adaugareuseri");
                            clearFieldsContent();
                        }
                        else
                        {
                            MessageBox.Show("Nu s-a realizat adaugare in fisier!");
                        }
                    }
                    if (indexTipUtilizator == 1)
                    {
                        Utilizator utilizator = new Utilizator(username, password, "administrator");
                        if (model.GetPersistentaUtilizator().AdaugareUtilizator(utilizator))
                        {
                            MessageBox.Show("Adaugare incheiata cu succes!");
                            model.SetTipOperatie("adaugareuseri");
                            clearFieldsContent();
                        }
                        else
                        {
                            MessageBox.Show("Nu s-a realizat adaugare in fisier!");
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Nu s-a introdus numele sau parola utilizatorului!");
            }
        }
        private ActionResult LoginInternal(string returnUrl)
        {
            Utilizator u = (Utilizator)TempData["tempLogin"];

            TempData.Clear();
            u.IS_ONLINE = true;
            //Session["LAST_LOGIN"] = DateTime.Now;
            Session["LAST_LOGIN"] = u.CURRENT_LOGIN = DateTime.Now;
            //string s = "{'IS_ONLINE':true}";
            u.Update();
            Session["CURENT_USER"]    = u;
            Session["CURENT_USER_ID"] = u.ID;
            FormsAuthentication.SetAuthCookie(u.USER_NAME, true);
            //NomenclatoareRepository nr = new NomenclatoareRepository(Convert.ToInt32(u.ID), conStr);
            NomenclatoareRepository nr = new NomenclatoareRepository(Convert.ToInt32(u.ID), Session["conStr"].ToString());
            Nomenclator             n  = (Nomenclator)nr.Find("TIP_UTILIZATORI", Convert.ToInt32(u.ID_TIP_UTILIZATOR)).Result;

            Session["CURENT_USER_TYPE"]     = n;
            Session["CURENT_USER_RIGHTS"]   = (Drept[])u.GetDrepturi().Result;
            Session["CURENT_USER_ACTIONS"]  = (SOCISA.Models.Action[])u.GetActions().Result;
            Session["CURENT_USER_SETTINGS"] = (Setare[])u.GetSetari().Result;
            Session["CURENT_USER_SOCIETATI_ADMINISTRATE"] = (SocietateAsigurare[])u.GetSocietatiAdministrate().Result;

            if (u.ID_SOCIETATE == null && (n != null && n.DENUMIRE.ToUpper() == "ADMINISTRATOR"))
            {
                //return Redirect(returnUrl ?? Url.Action("SelectSocietate", "UtilizatoriController"));
                return(RedirectToAction("SelectSocietate"));
            }
            else
            {
                Session["ID_SOCIETATE"] = u.ID_SOCIETATE;
                //SocietatiAsigurareRepository sar = new SocietatiAsigurareRepository(Convert.ToInt32(u.ID), conStr);
                SocietatiAsigurareRepository sar = new SocietatiAsigurareRepository(Convert.ToInt32(u.ID), Session["conStr"].ToString());
                SocietateAsigurare           sa  = (SocietateAsigurare)sar.Find(Convert.ToInt32(u.ID_SOCIETATE)).Result;
                Session["SOCIETATE_ASIGURARE"] = sa;

                //return RedirectToAction("Index", "Home");
                //return Redirect(returnUrl ?? Url.Action("Index", "Home"));
                //return Redirect(returnUrl ?? Url.Action("IndexMain", "Dashboard"));
                if (returnUrl != null && returnUrl != "/")
                {
                    return(Redirect(returnUrl));
                }
                else
                {
                    return(RedirectToAction("IndexMain", "Dashboard"));
                }
            }
        }
Beispiel #7
0
        public async Task <IActionResult> DeleteUser(string id)
        {
            string name = string.Empty;

            if (!String.IsNullOrEmpty(id))
            {
                Utilizator applicationUser = await userManager.FindByIdAsync(id);

                if (applicationUser != null)
                {
                    name = applicationUser.UserName;
                }
            }
            return(PartialView("_DeleteUser", name));
        }
Beispiel #8
0
        public void InsertUtilizatorTest()
        {
            var target = new Utilizator
            {
                IdRol  = 1,
                Activ  = false,
                Nume   = "t1e1sti1ng",
                Parola = "123"
            };

            if (target.Save().Status != StatusEnum.Errors)
            {
                Assert.Fail();
            }
        }
Beispiel #9
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        Utilizator utliz = Conexiune.Logare(txtLogare.Text, txtParola.Text);

        if (utliz != null)
        {
            Session["login"] = utliz.Nume;
            Session["type"]  = utliz.Tip;
            Response.Redirect("~/Pages/Home.aspx");
        }
        else
        {
            lblEr.Text = "Login failed";
        }
    }
Beispiel #10
0
 private void LoadData()
 {
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca bancile...";
     Banca.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca delegatii...";
     Delegat.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca drepturile...";
     Drept.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca facturile...";
     FacturaIntrare.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca facturile...";
     FacturaIesire.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca firmele...";
     Firma.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca platile...";
     Plata.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca platile...";
     PlataFactura.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca platile...";
     PozitieFacturaIesire.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca platile...";
     PozitieFacturaIntrare.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca produsele...";
     Produs.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca rolurile...";
     Rol.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca platile...";
     RolDrept.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca stocurile...";
     Stoc.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca utilizatorii...";
     Utilizator.GetAll();
 }
Beispiel #11
0
 public void BAdauga_Click(object sender, EventArgs e)
 {
     if (Validare())
     {
         LNume.ForeColor    = Color.Black;
         LPrenume.ForeColor = Color.Black;
         LBuget.ForeColor   = Color.Black;
         Utilizator u = new Utilizator(tNume.Text, tPrenume.Text, Convert.ToInt32(tBuget.Text));
         u.Optiune    = new List <string>();
         u.Preferinta = pref();
         u.Optiune.AddRange(optiuniSelectate);
         lAfisare.Text = u.ConversieLaSir();
         if (cmbTara.Text != null)
         {
             u.Tara_Pref = cmbTara.Text;
         }
         u.dataActualizare = DateTime.Now;
         u.dataRezervarii  = dtpUtilizator.Value;
         Random rnd = new Random();
         int    i   = rnd.Next(1, 3);
         if (u.Tara_Pref == "Romania")
         {
             orase.Clear();
             orase.Add("Bucuresti");
             orase.Add("Cluj");
             orase.Add("Suceava");
         }
         else if (u.Tara_Pref == "Grecia")
         {
             orase.Clear();
             orase.Add("Atena");
             orase.Add("Salonic");
             orase.Add("Volos");
         }
         else
         {
             orase.Clear();
             orase.Add("Madrid");
             orase.Add("Barcelona");
             orase.Add("Sevilia");
         }
         int   pret = rnd.Next(0, u.Buget);
         Sejur S    = new Sejur(u.Tara_Pref, orase[i], pret);
         adminUtilizatori.AddUtilizator(u, S);
         lAfisare.Text = S.Afisare();
         ResetareControale();
     }
 }
Beispiel #12
0
        public HttpResponseMessage CheckCredentials(HttpRequestMessage credentials)
        {
            var msg = new HttpResponseMessage();

            string userpass = credentials.Content.ReadAsStringAsync().Result;

            string[] usernamePasswordArray = userpass.Split(':');
            string   username   = usernamePasswordArray[0];
            string   password   = usernamePasswordArray[1];
            var      utilizator = new Utilizator();

            t_elev userelev = catalog.Elevi.Where(elevspecific => elevspecific.Email == username).FirstOrDefault();

            if (userelev == null)
            {
                t_profesor userprof = catalog.Profesorii.Where(profspecific => profspecific.Email == username).FirstOrDefault();

                if (userprof != null && userprof.Parola == password)
                {
                    utilizator.Tip = ut.profesor;
                    utilizator.Id  = userprof.Id;

                    msg.Content = new StringContent(JsonConvert.SerializeObject(utilizator));
                }
                else
                {
                    msg.StatusCode = HttpStatusCode.Unauthorized;
                    msg.Content    = new StringContent("Access denied");
                }
            }
            else
            {
                if (userelev.Parola == password)
                {
                    utilizator.Tip = ut.elev;
                    utilizator.Id  = userelev.Id;

                    msg.Content = new StringContent(JsonConvert.SerializeObject(utilizator));
                }
                else
                {
                    msg.StatusCode = HttpStatusCode.Unauthorized;
                    msg.Content    = new StringContent("Access denied");
                }
            }

            return(msg);
        }
Beispiel #13
0
 private void _verificareCont(object ob, EventArgs ev)
 {
     try
     {
         string _bdInfo     = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "Util.db3");
         var    _bd         = new SQLiteConnection(_bdInfo);
         var    _informatii = _bd.Table <Utilizator>();
         var    _verifica   = _informatii.Where(cl => cl.AdresaEmail == emailLogin.Text && cl.Parola == passLogin.Text &&
                                                cl.NumeClient == userLogin.Text).FirstOrDefault();
         if (_verifica != null)
         {
             ProgressDialog _progres = new ProgressDialog(this);
             _progres.SetMessage("Authenticating, please wait...");
             _progres.SetProgressStyle(ProgressDialogStyle.Horizontal);
             _progres.Progress = 0;
             _progres.Max      = 100;
             _progres.Show();
             int _incarca = 0;
             new Thread(new ThreadStart(delegate
             {
                 while (_incarca < 100)
                 {
                     _incarca         += 25;
                     _progres.Progress = _incarca;
                     Thread.Sleep(500);
                 }
                 Intent pag       = new Intent(this, typeof(MainActivity));
                 Utilizator _util = new Utilizator
                 {
                     NumeClient = userLogin.Text
                 };
                 pag.PutExtra("Username", JsonConvert.SerializeObject(_util));
                 StartActivity(pag);
                 Finish();
             })).Start();
         }
         else
         {
             Toast.MakeText(this, "Incorrect credentials! Do you have an account? If yes, try again!", ToastLength.Short).Show();
             emailLogin.SetTextColor(Color.IndianRed);
             passLogin.SetTextColor(Color.IndianRed);
         }
     }
     catch (SQLiteException eroare)
     {
         Toast.MakeText(this, eroare.ToString(), ToastLength.Short).Show();
     }
 }
Beispiel #14
0
        public void TestGettersPersonal()
        {
            Utilizator _utilzatorForTest = new Utilizator();

            _utilzatorForTest.Id = 223;

            _testPersonal.Id           = 1;
            _testPersonal.IdUtilizator = _utilzatorForTest.Id;
            _testPersonal.Nume         = "Mister";
            _testPersonal.Prenume      = "Bleedify";

            Assert.IsTrue(_testPersonal.Id == 1);
            Assert.IsTrue(_testPersonal.IdUtilizator == _utilzatorForTest.Id);
            Assert.IsTrue(String.Compare(_testPersonal.Nume, "Mister") == 0);
            Assert.IsTrue(String.Compare(_testPersonal.Prenume, "Bleedify") == 0);
        }
Beispiel #15
0
        private void btnModifica_Click(object sender, EventArgs e)
        {
            Utilizator U = new Utilizator(tNume.Text, tPrenume.Text, Convert.ToInt32(tBuget.Text));

            U.Preferinta = pref();
            U.Optiune    = new List <string>();
            U.Optiune.AddRange(optiuniSelectate);
            if (cmbTara.Text != null)
            {
                U.Tara_Pref = cmbTara.Text;
            }
            U.dataRezervarii = dtpUtilizator.Value;
            adminUtilizatori.updateUtilizator(U, id, Sejururi[id]);
            U.dataActualizare = DateTime.Now;
            ResetareControale();
        }
Beispiel #16
0
        public static UtilizatorModel ToModel(this Utilizator utilizator)
        {
            var functie = FunctieHelper.Get(utilizator.IDFunctie);

            return(new UtilizatorModel()
            {
                ID = utilizator.ID,
                Username = utilizator.Username,
                IDFunctie = utilizator.IDFunctie,
                Email = utilizator.Email,
                Functie = functie.Descriere,
                Prenume = utilizator.Prenume,
                Nume = utilizator.Nume,
                IDElev = utilizator.IDElev
            });
        }
Beispiel #17
0
        public void UpdateUtilizatorTest()
        {
            var target = new Utilizator
            {
                IdRol  = 1,
                Activ  = true,
                Nume   = "Modified",
                Parola = "1223",
                ID     = 1
            };

            if (target.Save().Status == StatusEnum.Errors)
            {
                Assert.Fail();
            }
        }
Beispiel #18
0
        public async Task <bool> UpdateUtilizatorAsync(Utilizator util)
        {
            try
            {
                var tracking = _databaseContext.Update(util);

                await _databaseContext.SaveChangesAsync();

                var isModified = tracking.State == Microsoft.EntityFrameworkCore.EntityState.Modified;
                return(isModified);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Beispiel #19
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            id = lstAfisare.SelectedIndex;
            Utilizator U = null;

            try
            {
                U = adminUtilizatori.getUtilizator(id);
            }
            catch (Exception ex)
            {
                lAfisare.Text = "Eroare: " + ex.Message;
            }
            if (U != null)
            {
                tNume.Text    = U.Nume;
                tPrenume.Text = U.Prenume;
                tBuget.Text   = Convert.ToString(U.Buget);
                foreach (var pr in groupBox2.Controls)
                {
                    if (pr is RadioButton)
                    {
                        var prbox = pr as RadioButton;
                        if (prbox.Text != U.Preferinta.ToString())
                        {
                            prbox.Checked = true;
                        }
                    }
                }
                foreach (var pr in groupBox1.Controls)
                {
                    if (pr is CheckBox)
                    {
                        var prBox = pr as CheckBox;
                        foreach (String dis in U.Optiune)
                        {
                            if (prBox.Text.Equals(dis))
                            {
                                prBox.Checked = true;
                            }
                        }
                    }
                }
                cmbTara.Text        = U.Tara_Pref.ToString();
                dtpUtilizator.Value = U.dataRezervarii;
            }
        }
Beispiel #20
0
        public ActionResult Register(Utilizator model)
        {
            var ConfirmareParola = Request.Form["pwd"];

            if (ModelState.IsValid && (model.Parola.Equals(ConfirmareParola)))
            {
                var PAROLA = SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(model.Parola));
                model.Parola = BitConverter.ToString(PAROLA).Replace("-", "").ToLower();
                if (model.Functie == "Operator")
                {
                    model.Functie = "OperatorCentru";
                }
                // Attempt to register the user
                try
                {
                    db.Utilizator.Add(model);
                    db.SaveChanges();
                    if (model.Functie == "Medic")
                    {
                        var Spital = Request.Form["Spital"];
                        var medic  = new Medic();
                        medic.Spital     = Spital;
                        medic.Utilizator = model;
                        db.Medic.Add(medic);
                        db.SaveChanges();
                    }
                    else if (model.Functie == "OperatorCentru")
                    {
                        var AdresaCentru   = Request.Form["AdresaCentru"];
                        var operatorCentru = new OperatorCentru();
                        operatorCentru.Adresa     = AdresaCentru;
                        operatorCentru.Utilizator = model;
                        db.OperatorCentru.Add(operatorCentru);
                        db.SaveChanges();
                    }
                    return(RedirectToAction("Index"));
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", e.StatusCode.ToString());
                }
            }


            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Beispiel #21
0
        public ActionResult LogIn(Utilizator viewModel)
        {
            var finde = Context.signUp.Where(e => e.Firma == viewModel.Firma && e.Password == viewModel.Password).SingleOrDefault();

            if (finde != null)
            {
                Session["Id"] = finde.Id;


                return(RedirectToAction("Index", "Index", new { id = (int)Session["Id"] }));
            }
            else
            {
                TempData["check"] = "Acest cont de utilizator nu exista in baza de date";
                return(RedirectToAction("Index", "Home"));
            }
        }
 public bool ActualizareUtilizator(string username, Utilizator utilizator)
 {
     try
     {
         XDocument xDocument = XDocument.Load(@numeFisier);
         var       element   = xDocument.Root.Elements(tagUtilizator).Where(e => e.Element(tagUsername).Value == username).Single();
         element.Element(tagUsername).Value      = utilizator.GetUsername();
         element.Element(tagPassword).Value      = utilizator.GetPassword();
         element.Element(tagTipUtilizator).Value = utilizator.GetTipUtilizator();
         xDocument.Save(@numeFisier);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #23
0
 private void AddEditUtilizatorForm_Load(object sender, EventArgs e)
 {
     if (UtilizatorObject == null)
     {
         UtilizatorObject      = new Utilizator();
         this.Text             = "Adauga utilizator";
         curentPwdTbox.Enabled = false;
     }
     else
     {
         curentPwdTbox.Enabled = true;
         this.Text             = "Modifica utilizator";
         numeTbox.Text         = UtilizatorObject.Nume;
         rolCmb.SelectedValue  = UtilizatorObject.IdRol;
         activeCkbox.Checked   = UtilizatorObject.Activ;
     }
 }
Beispiel #24
0
        public JsonResult GetSentMessages(int?id, int?_START_LIMIT, int?_END_LIMIT)    // id_dosar
        {
            MesajView mv     = new MesajView();
            string    conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            int       uid    = Convert.ToInt32(Session["CURENT_USER_ID"]);

            Dosar d     = new Dosar(uid, conStr, Convert.ToInt32(id));
            Mesaj mesaj = new Mesaj(uid, conStr);

            Utilizator[] us = (Utilizator[])mesaj.GetReceivers().Result;
            Utilizator   s  = (Utilizator)mesaj.GetSender().Result;
            Nomenclator  n  = (Nomenclator)mesaj.GetTipMesaj().Result;
            DateTime?    da = (DateTime?)mesaj.GetMessageReadDate(uid).Result;

            mv.MesajJson       = new MesajJson(mesaj, d, s, us, n, da);
            mv.InvolvedParties = (Utilizator[])d.GetInvolvedParties().Result;
            mv.TipuriMesaj     = (Nomenclator[])(new NomenclatoareRepository(uid, conStr).GetAll("tip_mesaje").Result);

            Mesaj[]          ms = null;
            List <MesajJson> ls = new List <MesajJson>();

            if (id != null)
            {
                d  = new Dosar(uid, conStr, Convert.ToInt32(id));
                ms = (Mesaj[])d.GetSentMesaje().Result;
            }
            else
            {
                Utilizator u = (Utilizator)Session["CURENT_USER"];
                ms = (Mesaj[])u.GetSentMesaje(_START_LIMIT, _END_LIMIT).Result;
            }

            foreach (Mesaj m in ms)
            {
                //ls.Add(new MesajJson(m, (Dosar)m.GetDosar().Result, (Utilizator)m.GetSender().Result, (Utilizator[])m.GetReceivers().Result, (Nomenclator)m.GetTipMesaj().Result, (DateTime?)m.GetMessageReadDate(uid).Result));
                MesajJson mj = new MesajJson(m);
                mj.DataCitire = (DateTime?)m.GetMessageReadDate(uid).Result;
                ls.Add(mj);
            }

            mv.MesajeJson = ls.ToArray();

            //return PartialView("_MesajeView", mv);
            return(Json(mv, JsonRequestBehavior.AllowGet));
        }
        private async Task LoadSharedKeyAndQrCodeUriAsync(Utilizator user)
        {
            // Load the authenticator key & QR code URI to display on the form
            var unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user);

            if (string.IsNullOrEmpty(unformattedKey))
            {
                await _userManager.ResetAuthenticatorKeyAsync(user);

                unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user);
            }

            SharedKey = FormatKey(unformattedKey);

            var email = await _userManager.GetEmailAsync(user);

            AuthenticatorUri = GenerateQrCodeUri(email, unformattedKey);
        }
Beispiel #26
0
        public async Task <IActionResult> Register(RegisterViewModel registerViewModel)
        {
            if (ModelState.IsValid)
            {
                var user = new Utilizator()
                {
                    UserName = registerViewModel.UserName,
                    CNP      = registerViewModel.CNP
                };
                var result = await _userManager.CreateAsync(user, registerViewModel.Password);

                if (result.Succeeded)
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(View("Login", registerViewModel));
        }
Beispiel #27
0
        public ActionResult Index([Bind(Include = "Email,Parola")] Utilizator utilizator)
        {
            var        PAROLA         = SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(utilizator.Parola));
            var        ParolaCriptata = BitConverter.ToString(PAROLA).Replace("-", "").ToLower();
            Utilizator ut             = new Utilizator();

            if ((ut = VerificareUtilizator(ParolaCriptata, utilizator.Email)) == null)
            {
                return(Content("You have to create an account"));
            }
            else
            {
                //return View("aici");
                Session["Utilizator"] = ut;
                return(RedirectToAction("Index", ut.Functie.Replace(" ", "")));
                // return RedirectToAction("Index", "Home");
            }
        }
 public bool AdaugareUtilizator(Utilizator utilizator)
 {
     try
     {
         XElement xElement = XElement.Load(@numeFisier);
         xElement.Add(new XElement(tagUtilizator,
                                   new XElement(tagUsername, utilizator.GetUsername()),
                                   new XElement(tagPassword, utilizator.GetPassword()),
                                   new XElement(tagTipUtilizator, utilizator.GetTipUtilizator())
                                   ));
         xElement.Save(@numeFisier);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #29
0
        public async Task <IActionResult> DeleteUser(string id, IFormCollection form)
        {
            if (!String.IsNullOrEmpty(id))
            {
                Utilizator applicationUser = await userManager.FindByIdAsync(id);

                if (applicationUser != null)
                {
                    IdentityResult result = await userManager.DeleteAsync(applicationUser);

                    if (result.Succeeded)
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }
            return(View());
        }
Beispiel #30
0
        //sterge un utilizator
        public bool stergeUtiliz(int id)
        {
            ResearchersEntities4 context = new ResearchersEntities4();

            if (cauta(id) == false)
            {
                return(false);
            }
            List <Utilizator> ut = getUsers();
            int rol = 0;

            for (int i = 0; i < ut.Count; i++)
            {
                if (ut.ElementAt(i).id == id)
                {
                    rol = (int)ut.ElementAt(i).rol;
                    break;
                }
            }
            if (rol == 1)
            {
                Student s = context.Student.Find(id);
                context.Student.Remove(s);
            }
            else if (rol == 2)
            {
                Profesor p = context.Profesor.Find(id);
                context.Profesor.Remove(p);
            }
            else if (rol == 3)
            {
                Asistent a = context.Asistent.Find(id);
                context.Asistent.Remove(a);
            }
            else
            {
                return(false);
            }
            Utilizator u = context.Utilizator.Find(id);

            context.Utilizator.Remove(u);
            context.SaveChanges();
            return(true);
        }
Beispiel #31
0
        public JsonResult GetNewMessages(string j, int?_START_LIMIT, int?_END_LIMIT)
        {
            dynamic x      = JsonConvert.DeserializeObject(j);
            string  conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            int     uid    = Convert.ToInt32(Session["CURENT_USER_ID"]);

            if (x.id_dosar != null)
            {
                DosareRepository dr = new DosareRepository(uid, conStr);
                Dosar            d  = (Dosar)dr.Find(Convert.ToInt32(x.id_dosar)).Result;
                //return Json(d.GetNewMesaje(Convert.ToDateTime(x.last_refresh)), JsonRequestBehavior.AllowGet);
                return(Json(d.GetNewMesaje(DateTime.ParseExact(Convert.ToString(x.last_refresh), CommonFunctions.DATE_TIME_FORMAT, System.Globalization.CultureInfo.InvariantCulture)), JsonRequestBehavior.AllowGet));
            }
            else
            {
                Utilizator u = (Utilizator)Session["CURENT_USER"];
                return(Json(u.GetNewMesaje(DateTime.ParseExact(Convert.ToString(x.last_refresh), CommonFunctions.DATE_TIME_FORMAT, System.Globalization.CultureInfo.InvariantCulture), _START_LIMIT, _END_LIMIT), JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #32
0
 public List<Drept> GetRights(Utilizator user)
 {
     var rightList = RolDrept.GetAll().Where(p => p.IdRol == user.IdRol).Select(p => p.DreptObject).ToList();
     return rightList;
 }
Beispiel #33
0
 //returneaza rolul utilizatorului (0=admin; 1=student; 2=profesor; 3=asistent)
 public int findUserIdentity(Utilizator ut)
 {
     return (int)ut.rol;
 }
Beispiel #34
0
 public int findUserIdentity(Utilizator u)
 {
     return repo.findUserIdentity(u);
 }