Beispiel #1
0
 public TestViewModel()
 {
     testModel         = new Models.TestModel();
     testModel.strTemp = "Initial String ^^";
     UpdateCommand     = new DelegateCommand(updateCommand);
     ClearCommand      = new DelegateCommand(clearCommand);
 }
Beispiel #2
0
        public IActionResult Index()
        {
            MyUsbDevice = UsbDevice.OpenUsbDevice(MyUsbFinder);
            string response;

            // If the device is open and ready
            if (MyUsbDevice == null)
            {
                response = "Device Not Found.";
            }
            else
            {
                response = "Device found";
            }
            var final = response + MyUsbDevice;

            Models.TestModel tm = new Models.TestModel();
            tm.Title   = response;
            tm.Content = final;



            return(View(tm));
            //return new ObjectResult(response + MyUsbDevice);
        }
Beispiel #3
0
        public IActionResult Calculate(Models.TestModel tm)
        {
            var an = new Models.AnswerModel();

            an.Ann = tm.val1 + tm.val2;

            return(View("Answer", an));
        }
Beispiel #4
0
 public ActionResult Test(Models.TestModel model)
 {
     model.Result  = $"You entered text `{model.Text}`. Selected `{model.Selected}`";
     model.MyItems = new List <Models.MyItemModel> {
         new Models.MyItemModel {
             Id = 1, Name = "First", UserName = "******"
         }, new Models.MyItemModel {
             Id = 2, Name = "Second", UserName = "******"
         },
     };
     return(View(model));
 }
Beispiel #5
0
        public ActionResult Create(Models.TestModel newTest)
        {
            int testId = 0;

            using (GlossaryModel db = new GlossaryModel())
            {
                try
                {
                    // hämtar språken och visar upp i en dropdown lista
                    Languages lang = new Languages();
                    lang.LangListMain = new SelectList(db.Languages, "Id", "Language");
                    lang.LangListSec  = new SelectList(db.Languages, "Id", "Language");
                    ViewBag.Languages = db.Languages.ToList();

                    // hämtar den inloggade användarens id från db
                    string username = System.Web.HttpContext.Current.User.Identity.Name;
                    int    userId   = (from u in db.Users
                                       where u.Username == username
                                       select u.Id).FirstOrDefault();

                    // skapar en instans av klassen Test (från db)
                    Test test = new Test();

                    // sparar testet i db från modellen
                    test.Name     = newTest.Name;
                    test.MainLang = newTest.MainLang;
                    test.SecLang  = newTest.SecLang;
                    test.Date     = DateTime.Now;
                    test.StatusId = 0;
                    test.UserId   = userId;

                    db.Tests.Add(test);
                    db.SaveChanges();

                    // hämtar testId från det nyss skapade testet och skickar användaren vidare till nästa vy med det specifika id
                    testId = test.Id;
                }
                catch (Exception e)
                {
                    // loggar eventuellt error
                    logger.Error(e, "Unable to save in database");
                }
            }
            return(RedirectToAction("CreateWords", "Words", new { id = testId }));
        }
Beispiel #6
0
        public ActionResult CheckBoxList()
        {
            Models.TestModel   m   = new Models.TestModel();
            Models.Elem        e   = new Models.Elem();
            List <Models.Elem> lst = new List <Models.Elem>();

            e.id    = 1;
            e.value = "one";
            lst.Add(e);

            e       = new Models.Elem();
            e.id    = 2;
            e.value = "two";
            lst.Add(e);

            m.id    = 1;
            m.Elems = lst;
            return(View(m));
        }
Beispiel #7
0
        private void ClickPlus()
        {
            if (CurrentTest == null)
            {
                return;
            }
            Models.BaseNode model = null;

            if (CurrentTest is Models.TestRootModel)
            {
                model = new Models.TestModel()
                {
                    Name = "Новый тест"
                }
            }
            ;
            else if (CurrentTest is Models.TestModel)
            {
                model = new Models.QuestionModel()
                {
                    Name = "Новый вопрос"
                }
            }
            ;
            else if (CurrentTest is Models.QuestionModel)
            {
                ((Models.QuestionModel)CurrentTest).Answers.Add(new Models.AnswerModel()
                {
                    Name = "Новый ответ"
                });
            }

            if (model == null)
            {
                return;
            }

            CurrentTest.Children.Add(model);
            CurrentTest = model;
        }
Beispiel #8
0
        public async Task <ActionResult> SMSTest(Models.TestModel data)
        {
            Models.TestModel result = new Models.TestModel();
            try
            {
                if (data != null && data.phone != null && data.phone != "" && data.message != null && data.message != "")
                {
                    string url = BLayer.Settings.GetValue(CLayer.Settings.SMS_URL);

                    System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
                    // string myParameters = "?workingkey=" + BLayer.Settings.GetValue(CLayer.Settings.SMS_API) + "&sender=" + BLayer.Settings.GetValue(CLayer.Settings.SMS_SENDER_ID) +
                    //"&to=" + data.phone + "&message=" + Server.UrlEncode(data.message);

                    string myParameters = "?username="******"&pass="******"&senderid=" + BLayer.Settings.GetValue(CLayer.Settings.SMS_SENDER_ID) +
                                          "&dest_mobileno=" + data.phone + "&message=" + Server.UrlEncode(data.message);
                    string s = await client.GetStringAsync(url + myParameters);

                    //System.Collections.Specialized.NameValueCollection reqparm = new System.Collections.Specialized.NameValueCollection();
                    //reqparm.Add("workingkey", BLayer.Settings.GetValue(CLayer.Settings.SMS_API));
                    //reqparm.Add("sender", BLayer.Settings.GetValue(CLayer.Settings.SMS_SENDER_ID));
                    //reqparm.Add("to", data.phone);
                    //reqparm.Add("message", Server.UrlEncode(data.message));
                    //WebClient client = new WebClient();
                    //byte[] responsebytes = client.UploadValues(url, "GET", reqparm);

                    //string responsebody = Encoding.UTF8.GetString(responsebytes);
                    result.emessage = "Result:" + s;
                }
                else
                {
                    data = new Models.TestModel();
                }
            }catch (Exception ex)
            {
                result.emessage = ex.Message;
            }
            return(View("SMSTest", result));
        }
		protected static string test05() {
			Models.TestModel test = new Models.TestModel();
			
			test.Id = 5;
			
			test.IntList = new AltairStudios.Core.Orm.ModelList<int>();
			test.IntList.Add(5);
			test.IntList.Add(7);
			test.IntList.Add(8);
			test.IntList.Add(3);
			
			return test.ToJson();
		}
 public TestViewModel(string args)
 {
   var id = Int32.Parse(args.Substring(args.IndexOf("=") + 1));
   _model = new Models.TestModel(id);
 }
 public TestViewModel()
 {
   _model = new Models.TestModel(0);
 }
		protected static string test06() {
			Models.TestModel test = new Models.TestModel();
			
			test.Id = 5;
			test.PasswordMd5 = "1234";
			test.PasswordSha1 = "1234";
			
			test.IntList = new AltairStudios.Core.Orm.ModelList<int>();
			test.IntList.Add(5);
			test.IntList.Add(7);
			test.IntList.Add(8);
			test.IntList.Add(3);
			
			test.UserList = new AltairStudios.Core.Orm.ModelList<AltairStudios.Core.Orm.Models.User>();
			
			AltairStudios.Core.Orm.Models.User userA = new AltairStudios.Core.Orm.Models.User();
			userA.Name = "Test";
			userA.Surname = "Test";
			userA.Email = "*****@*****.**";
			userA.Password = "******";
			test.UserList.Add(userA);
			
			return test.ToJson();
		}
        public async Task <IActionResult> Index()
        {
            //clear database
            ctx.Database.ExecuteSqlCommand("delete  from dbo.TestModels");
            //populate db
            var population = new List <Models.TestModel>();

            for (int i = 0; i < 10; i++)
            {
                var curr = new Models.TestModel
                {
                    FieldA = "FieldA_" + i,
                    FieldB = "FieldB_" + i,
                    FieldC = "FieldC_" + i,
                    FieldD = "FieldD_" + i,
                    FieldE = "FieldE_" + i,
                    FieldF = "FieldF_" + i
                };
                population.Add(curr);
                ctx.TestModels.Add(curr);
            }
            Expression <Func <Models.TestModel, bool> > test = m => (new int[] { 10, 3 }).Contains(m.Id);
            await ctx.SaveChangesAsync();

            //reset context...we are going into a different web page
            foreach (var item in population)
            {
                ctx.Entry(item).State = EntityState.Detached;
            }

            //
            //get data
            var original = await ctx.TestModels.Project().To <Models.TestViewModel>().ToArrayAsync();

            //

            //perform changes (this usually happens in user interface)...
            var copier  = new ObjectCopier <Models.TestViewModel, Models.TestViewModel>();
            var changed = original.Select(m => copier.Copy(m, new Models.TestViewModel())).ToList();

            changed[3].FieldD = "FieldD3_Changed";
            changed[5].FieldF = "FieldF%_Changed";
            changed.Remove(changed[7]);
            changed.Add(new Models.TestViewModel
            {
                FieldA = "FieldA_New",
                FieldB = "FieldB_Bew",
                FieldD = "FieldD_New",
                FieldE = "FieldE_New",
                FieldF = "FieldF_New"
            });
            //
            var repo =
                DefaultCRUDRepository.Create(ctx, ctx.TestModels, null, m => m.FieldA != "FieldA_0");

            DefaultCRUDRepository <ApplicationDbContext, Models.TestModel>
            .DeclareProjection <Models.ITestViewModel>(m => new Models.TestViewModel
            {
                FieldBC = m.FieldB + " " + m.FieldC
            });

            try
            {
                repo.Add <Models.ITestViewModel>(true, new Models.TestViewModel
                {
                    FieldA = "FieldA_ANew2",
                    FieldB = "FieldB_Bew2",
                    FieldD = "FieldD_New2",
                    FieldE = "FieldE_New",
                    FieldF = "FieldF_New"
                });
                repo.UpdateList <Models.ITestViewModel>(false, original, changed);
                changed[6].FieldA = "a change";
                changed[6].FieldF = "a F change";
                repo.Update <Models.ITestViewModel>(false, changed[6]);
                repo.Delete(changed[8].Id);
                await repo.SaveChanges();
            }
            catch (Exception ex)
            {
                var exc = ex;
            }
            //
            //Retrieve changed data and perform custo processing on ViewModel Projection
            var finalData = await repo.GetPage <Models.TestViewModel>(null,
                                                                      x => x.OrderBy(m => m.FieldA),
                                                                      1, 5);

            var finalData1 = await repo.GetPage <Models.TestViewModel>(null,
                                                                       x => x.OrderBy(m => m.FieldA),
                                                                       2, 5);

            var detail = await repo.GetById <Models.ITestViewModel, int>(original[1].Id.Value);

            return(View());
        }
		protected static string test04() {
			Models.TestModel test = new Models.TestModel();
			
			return test.ToJson();
		}
Beispiel #15
0
 public ActionResult CheckBoxList(Models.TestModel m)
 {
     return(View(m));
 }
Beispiel #16
0
 public ActionResult Update(int id, Models.TestModel m)
 {
     return(View());
 }
Beispiel #17
0
        public ActionResult GoToTest(char letter, string name, string needContent)
        {
            Models.TestModel m = new Models.TestModel();
            m.Letter        = letter;
            m.gameName      = name;
            m.contentNeeded = needContent;
            var specificContent = BLL.Services.ContentServices.LoadAllContents();

            specificContent = specificContent.Where(c => c.Data.IsApproved && c.Data.UnDotedWord.StartsWith(Char.ToString(letter))).ToList();
            specificContent = specificContent.OrderBy(x => Guid.NewGuid()).ToList();
            m.questions     = specificContent.Take(4).ToList();

            //get the words from class "Dictionaries"
            Auxiliray.Dictionaries d = new Auxiliray.Dictionaries();
            var words = d.Words;

            var wordsToDisplay = new List <string>(); // Variable for listing random words
            var j = 0;                                // Variable to know how many words in wordsToDisplay

            Random rnd    = new Random();
            var    number = -1;// Variable to get random position in "words"

            // While loop to add words to wordsToDisplay
            while (j < 13)// 13 means the amounts of words in wordsToDisplay
            {
                number = rnd.Next(words.Count);
                var word = words[number];
                var wordIsInQuestions = false;
                foreach (var q in m.questions)
                {
                    if (word == q.Word || wordsToDisplay.Contains(word))// if word is question answer or already in wordsToDisplay
                    {
                        wordIsInQuestions = true;
                        break;
                    }
                }
                if (!wordIsInQuestions)
                {
                    j++;
                    wordsToDisplay.Add(word);
                }
            }
            var wordWithWrongToLearn = new Dictionary <int, List <string> >();

            foreach (var q in m.questions)
            {
                var temp = new List <string>();
                temp.Add(q.Word);
                number = rnd.Next(wordsToDisplay.Count);
                var placeholderNumber = number;
                temp.Add(wordsToDisplay[number]);
                number = rnd.Next(wordsToDisplay.Count);
                while (number == placeholderNumber)
                {
                    number = rnd.Next(wordsToDisplay.Count);
                }
                temp.Add(wordsToDisplay[number]);
                temp = temp.OrderBy(x => Guid.NewGuid()).ToList();
                wordWithWrongToLearn.Add(q.ContentID, temp);
            }
            m.ContentOptions = wordWithWrongToLearn;
            if (Auxiliray.Session.ChildInSession.ChildID != -1)// if child is not a guest
            {
                BLL.LearnHebrewEntities.ChildProgress childProgress = new BLL.LearnHebrewEntities.ChildProgress();
                childProgress.ChildID             = Auxiliray.Session.ChildInSession.ChildID;
                childProgress.Data.ChosenContents = m.questions.ToDictionary(k => k.ContentID, v => v);
                childProgress.Data.Date           = DateTime.Now;
                childProgress.Data.EndDate        = DateTime.MaxValue;
                var progressID = BLL.Services.ChildProgressServices.Save(childProgress);
                m.childProgressID = childProgress.ProgressID;
            }
            var view = "~/Views/Child/Test.cshtml";

            return(View(view, m));
        }