Exemple #1
0
        // GET: /Plan/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Plans plans = db.Plans.Find(id);

            if (plans == null)
            {
                return(HttpNotFound());
            }

            var _Model = new PlanViewModel();

            _Model.Features = new List <PlanFeaturesViewModel>();
            var _features = db.Features.ToList();

            _Model.CreatedDate        = plans.CreatedDate;
            _Model.Description        = plans.Description;
            _Model.Notes              = plans.Notes;
            _Model.IsActive           = plans.IsActive;
            _Model.MonthlyPrice       = plans.MonthlyPrice;
            _Model.YearlyPrice        = plans.YearlyPrice;
            _Model.TotalMonthlyPrice  = plans.TotalMonthlyPrice;
            _Model.Plancode           = plans.Plancode;
            _Model.PlanFrequency      = plans.PlanFrequency;
            _Model.PlanName           = plans.PlanName;
            _Model.ProductBucketCount = plans.ProductBucketCount;
            _Model.TotalYearlyPrice   = plans.TotalYearlyPrice;
            _Model.UserBucketCount    = plans.UserBucketCount;
            _Model.Sort = plans.Sort;
            _Model.Id   = plans.Id;
            var _planFeatures = db.PlanFeatures.Where(x => x.PlanID == _Model.Id).ToList();

            _planFeatures = _planFeatures == null ? new List <PlanFeatures>() : _planFeatures;

            foreach (var item in _features)
            {
                var _isExisting = _planFeatures.Where(x => x.FeatureID == item.Id).FirstOrDefault();
                var _obj        = new PlanFeaturesViewModel();
                _obj.ID         = item.Id;
                _obj.title      = item.Title;
                _obj.IsSelected = _isExisting == null ? false : true;
                _obj.price      = item.Price;
                _Model.Features.Add(_obj);
            }
            return(View(_Model));
        }
Exemple #2
0
        public PlanViewModel GetViewBagData()
        {
            var _Model = new PlanViewModel();

            _Model.Features = new List <PlanFeaturesViewModel>();
            var _features = db.Features.ToList();

            foreach (var item in _features)
            {
                var _obj = new PlanFeaturesViewModel();
                _obj.ID         = item.Id;
                _obj.title      = item.Title;
                _obj.IsSelected = false;
                _obj.price      = item.Price;
                _Model.Features.Add(_obj);
            }

            return(_Model);
        }