Esempio n. 1
0
 public CustomerAppCreateEditModel WithUserInput(CustomerAppCreateEditModel inputModel)
 {
     ApplicationName      = inputModel.ApplicationName;
     SelectedLicenseGUIDs = inputModel.SelectedLicenseGUIDs;
     RedirectUrl          = inputModel.RedirectUrl;
     return(this);
 }
Esempio n. 2
0
        public ActionResult Create(CustomerAppCreateEditModel viewModel)
        {
            using (var context = this.dataContextFactory.CreateByUser())
            {
                if (ModelState.IsValid)
                {
                    if (viewModel.TryToSaveCustomerApp(context, (key, message) => ModelState.AddModelError(key, message)))
                    {
                        Flash.Success("The licensed application was created.");
                        return Redirect(viewModel.RedirectUrl ?? Url.Action("Index"));
                    }
                }

                var model = CustomerAppCreateEditModel.ForCreate(context).WithUserInput(viewModel);

                return View("CreateEdit", model);
            }
        }
        public static CustomerAppCreateEditModel ForCreate(IDataContextByUser context)
        {
            CustomerAppCreateEditModel viewModel;

            var availableLicenses = (from x in context.Licenses select x)
                .Include(x => x.Sku)
                .Include(x => x.OwningCustomer)
                .ToList();

            viewModel = new CustomerAppCreateEditModel()
            {
                LicenseList = availableLicenses.Select(l => new SelectListItem()
                {
                    Text = String.Format("{0} owned by {1}", l.Sku.SkuCode, l.OwningCustomer.Name),
                    Value = l.ObjectId.ToString()
                }).ToList(),
                SelectedLicenseGUIDs = new List<Guid>()
            };

            return viewModel;
        }
Esempio n. 4
0
        public static CustomerAppCreateEditModel ForCreate(IDataContextByUser context)
        {
            CustomerAppCreateEditModel viewModel;

            var availableLicenses = (from x in context.Licenses select x)
                                    .Include(x => x.Sku)
                                    .Include(x => x.OwningCustomer)
                                    .ToList();

            viewModel = new CustomerAppCreateEditModel()
            {
                LicenseList = availableLicenses.Select(l => new SelectListItem()
                {
                    Text  = String.Format("{0} owned by {1}", l.Sku.SkuCode, l.OwningCustomer.Name),
                    Value = l.ObjectId.ToString()
                }).ToList(),
                SelectedLicenseGUIDs = new List <Guid>()
            };

            return(viewModel);
        }
 public CustomerAppCreateEditModel WithUserInput(CustomerAppCreateEditModel inputModel)
 {
     ApplicationName = inputModel.ApplicationName;
     SelectedLicenseGUIDs = inputModel.SelectedLicenseGUIDs;
     RedirectUrl = inputModel.RedirectUrl;
     return this;
 }