Exemple #1
0
        public static MvcHtmlString CustomCheckBox(this HtmlHelper htmlHelper, string id, string label,
                                                   string dataBindingValue, int col = 6, bool isReadonly            = false, string cssClass = "k-checkbox",
                                                   object htmlAttribute             = null, string ngChangeFunction = "", bool isDisabled    = false, string moreClass = "", bool labelTop = false)
        {
            var attribute = new RouteValueDictionary();

            if (htmlAttribute != null)
            {
                attribute = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttribute);
            }

            attribute.Add("id", id);

            var viewModel = new CheckBoxViewModel
            {
                Id               = id,
                Label            = label,
                HtmlAttributes   = attribute,
                Class            = cssClass,
                DataBindingValue = dataBindingValue,
                ReadOnly         = isReadonly,
                Col              = col,
                NgChangeFunction = ngChangeFunction,
                IsDisabled       = isDisabled,
                MoreClass        = moreClass,
                LabelTop         = labelTop
            };

            return(htmlHelper.Partial("~/Views/Shared/Input/CheckBox.cshtml", viewModel));
        }
        public void should_set_the_correct_checked_value_from_the_viewmodel_for_false()
        {
            var viewModel = new CheckBoxViewModel { Active = false, Value = true };

            new CheckboxExpression<CheckBoxViewModel>(viewModel, c => c.Active, Prefix)
                .ToString().ShouldEqual("<input type=\"checkbox\" value=\"Active\" name=\"Active\"/>");
        }
Exemple #3
0
        public ActionResult Upsert(int?id)
        {
            ViewModel.Positions = _repository.GetAllPositions();
            var checkBoxList = new List <CheckBoxViewModel>();

            Candidate = new Candidate();

            if (id == null)
            {
                foreach (var p in ViewModel.Positions)
                {
                    checkBoxList.Add(new CheckBoxViewModel()
                    {
                        PositionID = p.PositionID,
                        CompanyID  = p.CompanyID,
                        Display    = p.PositionName,
                        IsActive   = false
                    });
                }

                ViewModel.PositionTypesCheckBoxes = checkBoxList;

                ViewModel.Candidate = Candidate;
                return(View(ViewModel));
            }

            Candidate = _repository.GetCandidate(id);

            foreach (var p in ViewModel.Positions)
            {
                CheckBoxViewModel cb = new CheckBoxViewModel()
                {
                    PositionID = p.PositionID,
                    CompanyID  = p.CompanyID,
                    Display    = p.PositionName
                };
                Application a = new Application()
                {
                    CandidateID = Candidate.CandidateID,
                    PositionID  = p.PositionID,
                    CompanyID   = p.CompanyID
                };
                if (Candidate.Applications.Contains(a))
                {
                    cb.IsActive = true;
                }

                checkBoxList.Add(cb);
            }

            ViewModel.PositionTypesCheckBoxes = checkBoxList;

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

            ViewModel.Candidate = Candidate;
            return(View(ViewModel));
        }
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            shoeVM.Shoes = await _db.Shoes.Include(m => m.ShoeTypes).Include(n => n.Brands).SingleOrDefaultAsync(x => x.Id == id);

            var results = from b in _db.Providers
                          select new
            {
                b.Id,
                b.Name,
                Checked = ((from a in _db.ProviderShoes where (a.ShoesID == id) && (a.ProviderID == b.Id) select a).Count() > 0)
            };
            var ProviderShoesCheckBoxList = new List <CheckBoxViewModel>();

            foreach (var c in results)
            {
                var checkBox = new CheckBoxViewModel();
                checkBox.Id      = c.Id;
                checkBox.Name    = c.Name;
                checkBox.Checked = c.Checked;
                ProviderShoesCheckBoxList.Add(checkBox);
            }
            shoeVM.providers = ProviderShoesCheckBoxList;
            if (shoeVM.Shoes == null)
            {
                return(NotFound());
            }
            return(View(shoeVM));
        }
Exemple #5
0
        public IObjectViewModel Add(ObjectType objectType)
        {
            ErrorMessage = string.Empty;

            var id   = MakeId();
            var name = $"Объект {id}";

            IObjectViewModel viewModel;
            IVariableWrapper variable;

            switch (objectType)
            {
            case ObjectType.Label:
                viewModel = new LabelViewModel(id, name, _dataProvider);
                break;

            case ObjectType.TextBox:
                variable  = CreateVariable(VariableType.String);
                viewModel = new TextBoxViewModel(id, name, variable, _dataProvider);
                break;

            case ObjectType.CheckBox:
                variable  = CreateVariable(VariableType.Bool);
                viewModel = new CheckBoxViewModel(id, name, variable, _dataProvider);
                break;

            case ObjectType.RadioButton:
                variable  = CreateVariable(VariableType.Bool);
                viewModel = new RadioViewModel(id, name, variable, _dataProvider)
                {
                    GroupName = GetRadioGroupName()
                };
                break;

            case ObjectType.DatePicker:
                variable  = CreateVariable(VariableType.Date);
                viewModel = new DatePickerViewModel(id, name, variable, _dataProvider);
                break;

            case ObjectType.TimePicker:
                variable  = CreateVariable(VariableType.Time);
                viewModel = new TimePickerViewModel(id, name, variable, _dataProvider);
                break;

            default:
                ErrorMessage = "Неизвестный тип объекта.";
                return(null);
            }

            viewModel.Properties.TabId        = _dataProvider.TabsRepository.SelectedTabIndex;
            viewModel.Properties.Left         = 20;
            viewModel.Properties.Top          = 20;
            viewModel.Properties.FontSettings = new FontSettings();
            ViewModels.Add(viewModel);
            Select(viewModel);
            ObjectModified?.Invoke(viewModel.Properties.Id);

            return(viewModel);
        }
        public void should_set_the_correct_name_with_prefix()
        {
            Prefix = "Primary";
            var viewModel = new CheckBoxViewModel { Active = true, Value = true };

            new CheckboxExpression<CheckBoxViewModel>(viewModel, c => c.Active, Prefix)
                .ToString().ShouldEqual("<input type=\"checkbox\" value=\"PrimaryActive\" name=\"PrimaryActive\" checked=\"checked\"/>");
        }
        public void should_add_specified_custom_html_attributes()
        {
            var viewModel = new CheckBoxViewModel { Active = true, Value = true };

            var expr = new CheckboxExpression<CheckBoxViewModel>(viewModel, c => c.Active, Prefix);
            expr.HtmlAttributes.Add("disabled", "disabled");

            expr.ToString().ShouldEqual("<input type=\"checkbox\" value=\"Active\" name=\"Active\" checked=\"checked\" disabled=\"disabled\"/>");
        }
        public IActionResult CheckBox(CheckBoxViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                return(this.View("CheckBoxResult", model));
            }

            return(this.View(model));
        }
Exemple #9
0
        public static RptMentorComment MakeRptMentorcomment(CheckBoxViewModel viewModel, BasicSurveyReportViewModel paramModel)
        {
            RptMentorComment rptComment = new RptMentorComment();

            rptComment.DetailCd   = viewModel.DetailCd;
            rptComment.Comment    = viewModel.CheckVal.ToString();
            rptComment.BasicYear  = paramModel.BizWorkYear;
            rptComment.BizWorkSn  = paramModel.BizWorkSn;
            rptComment.QuestionSn = paramModel.QuestionSn;

            return(rptComment);
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Appointment appointment = db.Appointments.Find(id);

            if (appointment == null)
            {
                return(HttpNotFound());
            }
            var Results = from p in db.Patients
                          select new
            {
                p.Id,
                p.Name,
                p.Owner,
                // If the current appointment is associated with a patient in the
                // AppointmentsToPatients table then set Checked to true.
                Checked = ((from ap in db.AppointmentsToPatients
                            where (ap.AppointmentId == id) && (p.Id == ap.PatientId)
                            select ap).Count() > 0)
            };
            var AssocViewModel = new AppointmentsViewModel();

            AssocViewModel.AppointmentId = appointment.Id;
            AssocViewModel.StartTime     = appointment.StartTime;
            AssocViewModel.EndTime       = appointment.EndTime;
            var myCheckBoxList      = new List <CheckBoxViewModel>();
            var myCheckBoxViewModel = new CheckBoxViewModel();

            foreach (var r in Results)
            {
                myCheckBoxViewModel.Id      = r.Id;
                myCheckBoxViewModel.Name    = r.Name;
                myCheckBoxViewModel.Checked = r.Checked;
                myCheckBoxList.Add(myCheckBoxViewModel);
                myCheckBoxViewModel = null;
                myCheckBoxViewModel = new CheckBoxViewModel();
            }
            AssocViewModel.Patients = myCheckBoxList;
            return(View(AssocViewModel));
            //return View(appointment);
        }
Exemple #11
0
        public static CheckBoxViewModel MakeCheckBoxViewModel(BasicSurveyReportViewModel paramModel, string detailCode, RptMentorComment rptMentorComment = null)
        {
            var viewModel = new CheckBoxViewModel();

            Console.WriteLine(detailCode);
            if (rptMentorComment == null)
            {
                viewModel.DetailCd = detailCode;
                viewModel.CheckVal = false;
            }
            else
            {
                viewModel.DetailCd = rptMentorComment.DetailCd;
                viewModel.CheckVal = bool.Parse(rptMentorComment.Comment);
            }

            return(viewModel);
        }
Exemple #12
0
        /// <summary>
        /// Добавление десериализуемого объекта
        /// </summary>
        public void Add(IFormObject formObject)
        {
            IObjectViewModel viewModel = null;

            if (formObject is CheckBoxObject)
            {
                viewModel = new CheckBoxViewModel((CheckBoxObject)formObject, _dataProvider);
            }
            else if (formObject is LabelObject)
            {
                viewModel = new LabelViewModel((LabelObject)formObject, _dataProvider);
            }
            else if (formObject is TextBoxObject)
            {
                viewModel = new TextBoxViewModel((TextBoxObject)formObject, _dataProvider);
            }
            else if (formObject is RadioButtonObject)
            {
                viewModel = new RadioViewModel((RadioButtonObject)formObject, _dataProvider);
            }
            else if (formObject is DateBoxObject)
            {
                viewModel = new DatePickerViewModel((DateBoxObject)formObject, _dataProvider);
            }
            else if (formObject is TimePickerObject)
            {
                viewModel = new TimePickerViewModel((TimePickerObject)formObject, _dataProvider);
            }

            if (viewModel == null)
            {
                return;
            }

            viewModel.Properties.Left       = formObject.Left;
            viewModel.Properties.Top        = formObject.Top;
            viewModel.Properties.IsSelected = false;
            viewModel.Properties.SetVisibility(formObject.IsVisible);
            viewModel.Properties.TabId = formObject.TabId;
            ViewModels.Add(viewModel);
            ObjectModified?.Invoke(viewModel.Properties.Id);
        }
        public IActionResult Create()
        {
            var results = from b in _db.Providers
                          select new
            {
                b.Id,
                b.Name,
                Checked = false
            };
            var ProviderShoesCheckBoxList = new List <CheckBoxViewModel>();

            foreach (var c in results)
            {
                var checkBox = new CheckBoxViewModel();
                checkBox.Id      = c.Id;
                checkBox.Name    = c.Name;
                checkBox.Checked = c.Checked;
                ProviderShoesCheckBoxList.Add(checkBox);
            }
            shoeVM.providers = ProviderShoesCheckBoxList;
            return(View(shoeVM));
        }
        public ActionResult Edit(int id = 0)
        {
            tblJeu jeu = bd.tblJeus.Find(id);

            /*var result = from genre in bd.tblGenres
             *           select new
             *           {
             *               genre.idGenre,
             *               genre.descriptionGenre,
             *               Checked = ((from jg in bd.JeuGenre where (jg.idJeu == jeu.idJeu)&(jg.idGenre == genre.idGenre) select jg).Count()>0)
             *           };*/

            var checkBoxListGenre          = new List <CheckBoxViewModel>();
            var checkBoxListTheme          = new List <CheckBoxViewModel>();
            var checkBoxListClassification = new List <CheckBoxViewModel>();

            foreach (tblGenre genre in bd.tblGenres)
            {
                CheckBoxViewModel newCheckBoxViewModel = new CheckBoxViewModel();

                newCheckBoxViewModel.Id          = genre.idGenre;
                newCheckBoxViewModel.Description = genre.descriptionGenre;
                newCheckBoxViewModel.Checked     = jeuDansUneListe(genre.tblJeus, jeu);
                checkBoxListGenre.Add(newCheckBoxViewModel);
            }

            foreach (tblTheme theme in bd.tblThemes)
            {
                CheckBoxViewModel newCheckBoxViewModel = new CheckBoxViewModel();

                newCheckBoxViewModel.Id          = theme.idTheme;
                newCheckBoxViewModel.Description = theme.descriptionTheme;
                newCheckBoxViewModel.Checked     = jeuDansUneListe(theme.tblJeus, jeu);
                checkBoxListTheme.Add(newCheckBoxViewModel);
            }

            foreach (tblClassification classification in bd.tblClassifications)
            {
                CheckBoxViewModel newCheckBoxViewModel = new CheckBoxViewModel();

                newCheckBoxViewModel.Id          = classification.idClassification;
                newCheckBoxViewModel.Description = classification.descriptionClassification;
                newCheckBoxViewModel.Checked     = jeuDansUneListe(classification.tblJeus, jeu);
                checkBoxListClassification.Add(newCheckBoxViewModel);
            }

            var myJeuViewModel = new JeuViewModel();

            myJeuViewModel.configurationMinimaleJeu = jeu.configurationMinimaleJeu;

            myJeuViewModel.devellopeurJeu = jeu.devellopeurJeu;

            myJeuViewModel.descriptionJeu = jeu.descriptionJeu;

            myJeuViewModel.nomJeu = jeu.nomJeu;

            /*foreach (var genre in result)
             * {
             *  myCheckBoxList.Add(new CheckBoxViewModel { Id = genre.idGenre, Description = genre.descriptionGenre, Checked = genre.Checked });
             * }*/

            myJeuViewModel.lesGenres = checkBoxListGenre;

            myJeuViewModel.lesThemes = checkBoxListTheme;

            myJeuViewModel.lesClassifications = checkBoxListClassification;

            return(View(myJeuViewModel));
        }