Пример #1
0
        public ActionResult Create(LicenseCreateViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (var context = dataContextFactory.CreateByUser())
                    {
                        Model.License license = viewModel.ToEntity(null);
                        context.Licenses.Add(license);

                        context.SaveChanges();
                        Flash.Success("The license was succesfully created.");
                    }

                    if (!string.IsNullOrEmpty(viewModel.RedirectUrl))
                    {
                        return(Redirect(viewModel.RedirectUrl));
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    return(View(viewModel));
                }
            }
            catch
            {
                throw;
            }
        }
Пример #2
0
        /// <summary>
        /// Create a single License
        /// </summary>
        /// <returns>Create License view</returns>
        public ActionResult Create()
        {
            using (var context = dataContextFactory.CreateByUser())
            {
                var skuQuery      = from x in context.SKUs select x;
                var customerQuery = from x in context.Customers select x;

                LicenseCreateViewModel viewModel = new LicenseCreateViewModel(skuQuery.ToList(), customerQuery.ToList());

                viewModel.UseLocalReferrerAsRedirectUrl(Request);

                return(View(viewModel));
            }
        }