コード例 #1
0
        public ActionResult SelectSocietate(FormCollection model)
        {
            string     conStr = Session["conStr"].ToString(); // ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            Utilizator u      = (Utilizator)Session["CURENT_USER"];
            SocietatiAsigurareRepository sar = new SocietatiAsigurareRepository(Convert.ToInt32(u.ID), conStr);

            SocietateAsigurare[] sas = (SocietateAsigurare[])sar.GetAll().Result;
            if (!ModelState.IsValid)
            {
                return(View(sas));
            }

            /* -- modelul cu lista --
             * if(model["item.ID"] != null)
             * {
             *  Session["ID_SOCIETATE"] = model["item.ID"];
             *  SocietateAsigurare sa = (SocietateAsigurare)sar.Find(Convert.ToInt32(model["item.ID"])).Result;
             *  Session["SOCIETATE_ASIGURARE"] = sa;
             *  return RedirectToAction("Index", "Home");
             * }
             */
            if (model["Societate"] != null && model["Societate"] != "")
            {
                Session["ID_SOCIETATE"] = model["Societate"];
                SocietateAsigurare sa = (SocietateAsigurare)sar.Find(Convert.ToInt32(model["Societate"])).Result;
                Session["SOCIETATE_ASIGURARE"] = sa;
                //return RedirectToAction("Index", "Home");
                return(RedirectToAction("IndexMain", "Dashboard"));
            }
            else
            {
                ModelState.AddModelError("", "Selectati societatea!");
                return(View(sas));
            }
        }
コード例 #2
0
        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"));
                }
            }
        }