Ejemplo n.º 1
0
        public void check(Test t)
        {
            int gnahatakan = 0;
            int test       = -1;
            int count      = 20 / Convert.ToInt32(t.Question.Count);

            foreach (var item in t.Question)
            {
                int     qonshac = item.Answers.ToList().First().id;
                Answers a       = (from k in context.Answers where k.id == qonshac select k).ToList().First();
                test = Convert.ToInt32(a.Question.test_id);
                if (a.isRight == 1)
                {
                    gnahatakan += count;
                }
            }

            User    u = Session["CurrentUser"] as User;
            Results r = new Results();

            r.score   = gnahatakan;
            r.test_id = test;
            r.user_id = u.id;
            context.Results.Add(r);
            context.SaveChanges();

            Response.Write(gnahatakan);
        }
Ejemplo n.º 2
0
        public ActionResult Add(User u)
        {
            string error = "";
            var    users = context.User.Where(m => m.login == u.login).ToList();

            if (String.IsNullOrEmpty(u.name) || String.IsNullOrEmpty(u.surname) || String.IsNullOrEmpty(u.login) || String.IsNullOrEmpty(u.password))
            {
                error = "Lracreq Bolor Dashter@";
            }
            else if (u.password.Length < 6)
            {
                error = "password@ karch e";
            }
            else if (users.Count > 0)
            {
                error = "mutqagreq urish login";
            }



            if (error == "")
            {
                u.password = SecurePasswordHasher.Hash(u.password);
                context.User.Add(u);
                context.SaveChanges();
            }
            else
            {
                //Session["msg"] = error;
                TempData["msg"] = error;
            }


            return(Redirect("/User/Index"));
        }
Ejemplo n.º 3
0
 public void save(Test t)
 {
     using (TestingPlatformEntities context = new TestingPlatformEntities())
     {
         User u = Session["CurrentUser"] as User;
         t.user_id = u.id;
         context.Test.Add(t);
         context.SaveChanges();
     }
 }
Ejemplo n.º 4
0
        public void AddFriend()
        {
            int id     = Convert.ToInt32(Request.Params["id"]);
            int myself = (Session["CurrentUser"] as User).id;

            Requests r = new Requests();

            r.from = myself;
            r.to   = id;
            context.Requests.Add(r);
            context.SaveChanges();
            Response.Write(myself + " " + id);
        }