Example #1
0
 public ActionResult Group(Person person)
 {
     ViewBag.UsersList = Person.GetRealtivesForCurrentUser(person.oid, person.fid);
     Person orig = new Person();
     orig = Person.GetPersonByID(person.oid);
     if (!String.IsNullOrEmpty(person.fid.ToString()) && !String.Equals(person.fid.ToString(), orig.fid.ToString()))
     {
         Person.UpdateField(person.oid, "fid", person.fid.ToString());
         orig.fid = person.fid;
     }
     Person.WritePersonToSession(orig.Login);
     ViewBag.fid = person.fid.ToString();
     return View();
 }
Example #2
0
        public static Person GetPersonByID(int id)
        {
            SQLCmd = new SqlCommand("Select * from Persons where oid = '" + id.ToString() + "'", SQLCon);
            SQLDR = SQLCmd.ExecuteReader(CommandBehavior.Default);

            Person NewPerson = new Person();

            while (SQLDR.Read())
            {
                NewPerson.Login = "";
                NewPerson.Login += SQLDR["Login"].ToString();
                NewPerson.Name = "";
                NewPerson.Name += SQLDR["Name"].ToString();
                NewPerson.SecondName = "";
                NewPerson.SecondName += SQLDR["SecondName"].ToString();
                int tmp = 0;
                int.TryParse(SQLDR["fid"].ToString(), out tmp);
                NewPerson.fid = tmp;
                NewPerson.oid = id;
            }
            SQLDR.Close();

            return NewPerson;
        }
Example #3
0
 public ActionResult SignUp(Person person)
 {
     if (Person.IsUnique(person.Login))
     {
         Person.InsertNewEmptyUser(person.Login, person.Pass);
     }
     else
     {
         ViewBag.ErrorMsg = "<div class=\"alert alert-error\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button><h4>Такой пользователь уже существует</h4></div>";
         return View("signup");
     }
     Person.WritePersonToSession(person.Login);
     return View("welcome", person);
 }
Example #4
0
        public ActionResult Profile(Person person)
        {
            //Person.UpdateField(person.oid, "Name", person.Name);
            //Person.UpdateField(person.oid, "SecondName", person.SecondName);
            Person orig = new Person();
            orig = Person.GetPersonByID(person.oid);
            if (!String.IsNullOrEmpty(person.Name) && !String.Equals(person.Name, orig.Name))
            {
                Person.UpdateField(person.oid, "Name", person.Name);
                orig.Name = person.Name;
            }
            if (!String.IsNullOrEmpty(person.SecondName) && !String.Equals(person.SecondName, orig.SecondName))
            {
                Person.UpdateField(person.oid, "SecondName", person.SecondName);
                orig.SecondName = person.SecondName;
            }
            Person.WritePersonToSession(orig.Login);

            ViewBag.ErrorMsg = "<div class=\"alert alert-success\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button><h4>Ваши данные обновлены</h4></div>";

            return View();
        }
Example #5
0
        public ActionResult LogIn(Person person)
        {
            string lires = person.LogIn();
            Person.WritePersonToSession(person.Login);
            ViewBag.ErrorMsg = "";
            switch (lires)
            {
                case "notfound":
                    ViewBag.ErrorMsg += "<div class=\"alert alert-error\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button><h4>Неправильный логин</h4></div>";
                    return View("LogIn", person);
                    break;
                case "wrongpass":
                    ViewBag.ErrorMsg += "<div class=\"alert alert-error\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button><h4>Неправильный пароль</h4></div>";
                    return View("LogIn", person);
                    break;
            }

            return View("welcome", person);
        }
Example #6
0
 public static Person GetPersonFromSession()
 {
     Person person = new Person();
     int tmpint = 0;
     System.Web.SessionState.HttpSessionState Session = HttpContext.Current.Session;
     try
     {
         int.TryParse(Session["oid"].ToString(), out tmpint);
         person.oid = tmpint;
     }
     catch { }
     try
     {
         int.TryParse(Session["fid"].ToString(), out tmpint);
         person.fid = tmpint;
     }
     catch { }
     try
     {
         person.Login = Session["Login"].ToString();
     }
     catch { }
     try
     {
         person.Name = Session["Name"].ToString();
     }
     catch { }
     try
     {
         person.SecondName = Session["SecondName"].ToString();
     }
     catch { }
     return person;
 }