public IActionResult Create(PackageCreationBindingModel bindingModel)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction());
            }

            packagesService.CreatePackage(bindingModel);

            return(Redirect("/Packages/Pending"));
        }
Exemple #2
0
        public void CreatePackage(PackageCreationBindingModel packageCreationBindingModel)
        {
            Package package = new Package
            {
                Description     = packageCreationBindingModel.Description,
                Weight          = packageCreationBindingModel.Weight,
                Recipient       = context.Users.SingleOrDefault(user => user.UserName == packageCreationBindingModel.Recipient),
                ShippingAddress = packageCreationBindingModel.ShippingAddress,
                ShippingStatus  = PackageStatus.Pending
            };

            context.Packages.Add(package);
            context.SaveChanges();
        }