예제 #1
0
        public ViewResult Index(string activeOly = "all",
                                string activeCat = "all")
        {
            var model = new FlagViewModel
            {
                ActiveOly = activeOly,
                ActiveCat = activeCat,
                Games     = context.Game.ToList(),
                Sport     = context.Sport.ToList()
            };

            /* need to fix this
             *
             * //get countries - filter by Olympic and Category
             * IQueryable<Flag> query = context.Country;
             * if (activeOly != "all")
             *  query = query.Where(
             *      t => t.Olympic.Game.ToLower() ==
             *      activeOly.ToLower());
             * if (activeCat != "all")
             *  query = query.Where(
             *      t => t.Category.Sport.ToLower() ==
             *      activeCat.ToLower());
             *
             * // pass teams to view as model
             * model.Country = query.ToList();
             */
            return(View(model));
        }
예제 #2
0
        public ActionResult FlagLoad(FlagViewModel Flag)
        {
            OrderFlag _flag = Flag.ToFlag();

            using (OrderFlagBusiness flagBusiness = new OrderFlagBusiness(_applicationServicesSetup, _user))
            {
                if (_flag.Id > 0)
                {
                    flagBusiness.Modify(_flag);
                }
                else
                {
                    int Id      = flagBusiness.Create(_flag);
                    var NewFlag = flagBusiness.GetById(Id, new[] {
                        Globals.Related.OrderFlag.FlaggedByUser
                    });

                    Flag = new FlagViewModel(NewFlag);
                }


                if (flagBusiness.ValidationErrors.Any())
                {
                    ValidationErrorResponse(flagBusiness.ValidationErrors);
                }
            }

            return(Json(Flag));
        }
예제 #3
0
        public ActionResult CheckResponse(string currentFlagName, string response, List <Flag> currentCollection)
        {
            string check = String.Empty;

            if (response == currentFlagName)
            {
                check = "Resposta correta :)";
            }
            else
            {
                check = "Resposta incorreta :|";
            }

            var newCollection = ShuffleCollection(CollectionWithoutCurrentFlag(currentFlagName, currentCollection));

            FlagViewModel fvm = new FlagViewModel();

            fvm.flag            = GetCurrentFlag(newCollection);
            fvm.AnswerCheck     = check;
            fvm.AllFlags        = newCollection;
            fvm.FlagsToQuestion = GetCountriesForQuiz(newCollection);

            var result = JsonConvert.SerializeObject(fvm);

            return(Json(result));
        }
예제 #4
0
        // GET: Flags
        public ActionResult Index()
        {
            //Takes collection from Json and shuffles
            var flags = GetAllFlags();

            var shuffledflags = ShuffleCollection(flags);

            FlagViewModel flagsvm = new FlagViewModel();

            flagsvm.flag            = GetFirstFlag(shuffledflags);
            flagsvm.AllFlags        = shuffledflags;
            flagsvm.FlagsToQuestion = GetCountriesForQuiz(shuffledflags);

            return(View(flagsvm));
        }
        public async Task <ActionResult> RemoveContent(int?id)
        {
            if (!IsAdminUser())
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var flag = await db.Flags.FindAsync(id);

            if (flag == null || !IsAdminUser() || flag.IsReviewed)
            {
                return(HttpNotFound());
            }
            if (flag.FlaggedObject == FlaggedObject.LandLord)
            {
                var landlord = db.LandLords.Find(flag.FlaggedObjectId);
                var vm       = new FlagViewModel();
                vm.LandLord = landlord;
                vm.Flag     = flag;
                return(View("RemoveLandLord", vm));
            }
            if (flag.FlaggedObject == FlaggedObject.Rating)
            {
                var rating = db.Ratings.Find(flag.FlaggedObjectId);
                var vm     = new FlagViewModel();
                vm.Rating = rating;
                vm.Flag   = flag;
                return(View("RemoveRating", vm));
            }
            if (flag.FlaggedObject == FlaggedObject.RatingReply)
            {
                var ratingreply = db.RatingReplies.Find(flag.FlaggedObjectId);
                var vm          = new FlagViewModel();
                vm.RatingReply = ratingreply;
                vm.Flag        = flag;
                return(View("RemoveRatingReply", vm));
            }
            return(RedirectToAction("Index", "Admin"));
        }
예제 #6
0
        private void FillView3DFlags(IEnumerable <string> flagsNames, ICollection <IFlag> flags)
        {
            foreach (PropertyDescriptor item in System.ComponentModel.TypeDescriptor.GetProperties(view3DX, new Attribute[] { new PropertyFilterAttribute(PropertyFilterOptions.All) }))
            {
                var dpp = DependencyPropertyDescriptor.FromProperty(item);

                if ((dpp != null) && flagsNames.Any(s => string.Compare(s, dpp.Name) == 0))
                //if ((dpp != null) && (string.Compare(dpp.PropertyType.FullName, typeof(bool).FullName) == 0) && !dpp.IsReadOnly)
                {
                    var vm = new FlagViewModel()
                    {
                        Name = dpp.Name
                    };
                    var binding = new Binding("Value");

                    binding.Source = vm;
                    view3DX.SetBinding(dpp.DependencyProperty, binding);

                    flags.Add(vm);
                }
            }
        }
 public ActionResult Save(FlagViewModel model)
 {
     ViewBag.SavedValues = model.FlagProperty.ToString();
     return(View("~/Views/Home/Index.cshtml", model));
 }