コード例 #1
0
ファイル: UserController.cs プロジェクト: SZMAL/webapp
        public ActionResult Map()
        {
            if (!Logged())
            {
                return(RedirectToAction("Index", "Login"));
            }
            szmalDBEvents  db             = new szmalDBEvents();
            UserLoginModel userLoginModel = new UserLoginModel();
            var            bigmodel       = new BigModel()
            {
                EventToShowModel = db.zgloszenies.Select(s => s), UserLoginModel = null
            };

            return(View("~/Views/Home/Map.cshtml", bigmodel));
        }
コード例 #2
0
        public async Task Test_Execute_WithColumnBindingToProperty()
        {
            BigModel model1 = new BigModel()
            {
                Value = 1, Value2 = "banana"
            };
            BigModel model2 = new BigModel()
            {
                Value = 1, Value2 = "banana"
            };

            ITuple tuple1 = DatabaseHelper.Default.Relation(model1, "Value", "Value2").Row();
            ITuple tuple2 = DatabaseHelper.Default.Relation(model2, "Value", "Value2").Row();

            CommandData command1 = new CommandData()
            {
                CommandText = @"SELECT 2 AS B1, 'apple' AS B2;",
                Bindings    = new ICommandBinding[]
                {
                    new ColumnBinding("B1", tuple1[0]),
                    new ColumnBinding("B2", tuple1[1]),
                }
            };
            CommandData command2 = new CommandData()
            {
                CommandText = @"SELECT 2 AS B1, 'apple' AS B2;",
                Bindings    = new ICommandBinding[]
                {
                    new ColumnBinding("B1", tuple2[0]),
                    new ColumnBinding("B2", tuple2[1]),
                }
            };

            DatabaseHelper.Default.Execute(command1);
            await DatabaseHelper.Default.ExecuteAsync(command2);

            tuple1[0].Value.ShouldBe(2);
            tuple2[0].Value.ShouldBe(2);

            model1.Value.ShouldBe(2);
            model2.Value.ShouldBe(2);

            tuple1[1].Value.ShouldBe("apple");
            tuple2[1].Value.ShouldBe("apple");

            model1.Value2.ShouldBe("apple");
            model2.Value2.ShouldBe("apple");
        }
コード例 #3
0
        public async Task Test_Execute_WithColumnBindingToMissingValue_Throws()
        {
            BigModel model = new BigModel();

            IField field = DatabaseHelper.Default.Relation(model, "OneToOne.Value").Scalar();

            CommandData command = new CommandData()
            {
                CommandText = @"SELECT 12 AS B1",
                Bindings    = new ICommandBinding[]
                {
                    new ColumnBinding("B1", field),
                }
            };

            Should.Throw <Relations.BindingException>(() => DatabaseHelper.Default.Execute(command));
            await Should.ThrowAsync <Relations.BindingException>(async() => await DatabaseHelper.Default.ExecuteAsync(command));
        }
コード例 #4
0
        // GET: Logins
        public ActionResult Index()
        {
            szmalDBEvents  db             = new szmalDBEvents();
            UserLoginModel userLoginModel = new UserLoginModel();

            if (Session["UserID"] != null)
            {
                return(RedirectToAction("Yours", "User"));
            }


            var bigmodel = new BigModel()
            {
                EventToShowModel = db.zgloszenies.Select(s => s), UserLoginModel = null
            };

            return(View("Index", bigmodel));
        }
コード例 #5
0
        public ActionResult ProfileEditor()
        {
            var userProf = new Profile();

            userProf        = ReturnProfile(Session["Username"].ToString());
            ViewBag.Current = userProf;
            //------TAGS-----\\

            List <ProfileTags> list = new List <ProfileTags>();

            using (var cn = new SqlConnection(Constants.ConnString))
            {
                string _sql = @"SELECT * FROM Tags";
                var    cmd  = new SqlCommand(_sql, cn);
                cn.Open();
                var reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    ProfileTags t = new ProfileTags
                    {
                        TagID   = (int)reader["Id"],
                        TagName = (string)reader["TagName"]
                    };
                    list.Add(t);
                }

                cn.Close();
            }

            var DBModel = new ProfileTagsList()
            {
                DBTags = list
            };

            var BigModel = new BigModel
            {
                ProfileTagsList = DBModel
            };

            //-----END TAGS-----\\

            return(View(BigModel));
        }
コード例 #6
0
        // GET: Posts/5
        public async Task <IActionResult> Post(int?id)
        {
            BigModel bm = new BigModel();

            if (id == null)
            {
                return(NotFound());
            }

            var post = await _context.Posts
                       .SingleOrDefaultAsync(m => m.PostID == id);

            if (post == null)
            {
                return(NotFound());
            }
            post.Comments = await _context.Comments.ToListAsync();

            post.Comments = post.Comments.Where(c => c.PostID == post.PostID).ToList();
            bm.post       = post;
            bm.comment    = new Comment();

            return(View(bm));
        }
コード例 #7
0
        public ActionResult LoginUser(BigModel objUser)
        {
            using (szmaldbEntities db = new szmaldbEntities())
            {
                var obj = db.uzytkowniks.Where(a => a.login.Equals(objUser.UserLoginModel.Login) && a.haslo.Equals(objUser.UserLoginModel.Password)).FirstOrDefault();

                if (obj == null)
                {
                    ModelState.AddModelError("Login", "Niepoprawna nazwa użytkownika lub hasło");
                    ModelState.AddModelError("Password", "");
                    ViewResult result = View("~/Views/Index.cshtml", objUser);

                    return(result);
                }

                else if (ModelState.IsValid)
                {
                    Session["UserID"] = obj;
                    return(RedirectToAction("Yours", "User"));
                }

                return(View(this));
            }
        }
コード例 #8
0
 public ActionResult RegisterUser(BigModel objUser)
 {
     if (ModelState.IsValid)
     {
         using (szmaldbEntities db = new szmaldbEntities())
         {
             var obj = db.uzytkowniks.Where(a => a.imie.Equals(objUser.UserLoginModel.Login) && a.haslo.Equals(objUser.UserLoginModel.Password)).FirstOrDefault();
             if (obj == null)
             {
                 uzytkownik u = new uzytkownik();
                 u.login = objUser.UserLoginModel.Login;
                 u.haslo = objUser.UserLoginModel.Password;
                 u.email = objUser.UserLoginModel.Email;
                 db.uzytkowniks.Add(u);
                 db.SaveChanges();
             }
         }
     }
     else
     {
         return(PartialView("Index", objUser));
     }
     return(View("~/Views/Index.cshtml"));
 }
コード例 #9
0
        public ActionResult Create(BigModel bigModels)
        {
            // Loop and insert records.


            foreach (var allSurvey in bigModels.AllSurvey)
            {
                allSurvey.Status     = SurveyStatus.NOT_HAPPENNING_YET;
                allSurvey.CreateDate = DateTime.Now;
                allSurvey.UpdateDate = DateTime.Now.AddDays(7);
                db.Surveys.Add(allSurvey);
                db.SaveChanges();
                int    newIdSurvey = db.Surveys.Max(s => s.SurveyId);
                int    newIdQuest  = 0;
                string titleTemp;
                int    sttQuest = 0;
                for (int i = 0; i < bigModels.Question.Count; i++)
                {
                    bigModels.Question[i].SurveyId = newIdSurvey;
                    db.Questions.Add(bigModels.Question[i]);
                    db.SaveChanges();
                    if (i == 0)
                    {
                        newIdQuest = db.Questions.Max(q => q.Id);
                    }
                    if (bigModels.Question[i].Type == 3)
                    {
                        QaTemp q = new QaTemp();
                        q.Answer = "Other";
                        q.Title  = bigModels.Question[i].Title;
                        bigModels.QaTemps.Add(q);
                    }
                    if (bigModels.Question[i].Type == 4)
                    {
                        QaTemp q = new QaTemp();
                        q.Answer = "Essay";
                        q.Title  = bigModels.Question[i].Title;
                        bigModels.QaTemps.Add(q);
                    }
                    if (i == bigModels.Question.Count - 1)
                    {
                        titleTemp = bigModels.Question[sttQuest].Title;
                        foreach (var qaTemp in bigModels.QaTemps)
                        {
                            QuestionAnswer questionAnswer = new QuestionAnswer();
                            if (!qaTemp.Title.Equals(titleTemp))
                            {
                                titleTemp = qaTemp.Title;
                                newIdQuest++;
                                sttQuest++;
                            }
                            questionAnswer.Answer     = qaTemp.Answer;
                            questionAnswer.QuestionId = newIdQuest;
                            questionAnswer.Answer     = qaTemp.Answer;
                            db.Question_answers.Add(questionAnswer);
                            //bigModels.QaTemps.Remove(qaTemp);
                        }
                    }
                }
            }
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }