public IActionResult Create(PackageCreateBindingModel model) { var recipientName = this.User.Identity.Name; this.packageService.CreatePackage(recipientName, model.Weight, model.ShippingAddress, model.Description); return(this.Redirect("/Home/Index")); }
public IActionResult Create() { var bindingModel = new PackageCreateBindingModel(); var recipients = this.userManager.Users.ToList(); bindingModel.Recipients = recipients; return(this.View(bindingModel)); }
public IActionResult Create(PackageCreateBindingModel model) { if (!ModelState.IsValid) { return(this.Redirect("/Packages/Create")); } this.packageServices.Create(model.Description, model.Weight, model.ShippingAddress, model.Recipient); return(this.Redirect("/")); }
public IActionResult Create(PackageCreateBindingModel bindingModel) { Package package = new Package { Description = bindingModel.Description, Weight = bindingModel.Weight, ShippingAddress = bindingModel.ShippingAddress, Recipient = this.db.Users.SingleOrDefault(x => x.UserName == bindingModel.Recipient), Status = this.db.PackageStatus.SingleOrDefault(x => x.Name == "Pending") }; this.db.Packages.Add(package); this.db.SaveChanges(); return(this.Redirect("/Package/Pending")); }
public IActionResult Create(PackageCreateBindingModel bindingModel) { if (!this.ModelState.IsValid) { return(this.Redirect("/Package/Create")); } var isPackageCreated = this.packageService.CreatePackage(bindingModel); if (!isPackageCreated) { return(this.Redirect("/Package/Create")); } return(this.Redirect("/Package/Pending")); }
public IActionResult Create(PackageCreateBindingModel bindingModel) { var package = new Package() { Description = bindingModel.Description, Recipient = this.context.Users.SingleOrDefault(x => x.UserName == bindingModel.Recipient), ShippingAddress = bindingModel.ShippingAddress, Weight = bindingModel.Weight, Status = this.context.PackageStatuses.FirstOrDefault(status => status.Name == "Pending") }; this.context.Packages.Add(package); this.context.SaveChanges(); return(Redirect("/Package/Pending")); }
public IActionResult Create(PackageCreateBindingModel model) { var package = new Package { Description = model.Description, Recipient = this.context.Users.SingleOrDefault(user => user.UserName == model.Recipient), ShippingAddress = model.ShippingAddress, Wight = model.Weight, Status = this.context.PackageStatus.SingleOrDefault(status => status.Name == "Pending"), }; this.context.Packages.Add(package); this.context.SaveChanges(); return(this.Redirect("/Packages/Pending")); }
public IActionResult Create(PackageCreateBindingModel bindingModel) { if (!this.ModelState.IsValid) { return(this.View(bindingModel ?? new PackageCreateBindingModel())); } Package package = new Package { Description = bindingModel.Description, Recipient = this.usersService.GetUser(bindingModel.Recipient), ShippingAddress = bindingModel.ShippingAddress, Weight = bindingModel.Weight, Status = this.packagesService.GetPackageStatus("Pending") }; this.packagesService.AddPackage(package); return(this.Redirect("/Packages/Pending")); }
public IActionResult Create(PackageCreateBindingModel bindingModel) { if (!ModelState.IsValid) { return(Redirect("/Package/Create")); } var package = new Package() { Description = bindingModel.Description, Weight = bindingModel.Weight, Recipient = this.context.Users.SingleOrDefault(x => x.UserName == bindingModel.Recipient), ShippingAddress = bindingModel.ShippingAddress, Status = this.context.PackageStatus.SingleOrDefault(x => x.Name == ConstPackageStatusPending) }; this.context.Packages.Add(package); this.context.SaveChanges(); return(this.Redirect("/Packages/Pending")); }
public IActionResult Create(PackageCreateBindingModel bindingModel) { if (!this.ModelState.IsValid) { return(this.View(bindingModel ?? new PackageCreateBindingModel())); } Package package = new Package { Description = bindingModel.Description, Recipient = this.context.Users.SingleOrDefault(user => user.UserName == bindingModel.Recipient), ShippingAddress = bindingModel.ShippingAddress, Weight = bindingModel.Weight, Status = this.context.PackageStatus.SingleOrDefault(status => status.Name == "Pending") }; this.context.Packages.Add(package); this.context.SaveChanges(); return(this.Redirect("/Packages/Pending")); }
public bool CreatePackage(PackageCreateBindingModel bindingModel) { var recipient = this.context.Users.FirstOrDefault(x => x.UserName == bindingModel.Recipient); if (recipient == null) { return(false); } var package = new Package { Description = bindingModel.Description, Weight = bindingModel.Weight, ShippingAddress = bindingModel.ShippingAddress, Status = PackageStatus.Pending, Recipient = (PandaUser)recipient, EstimatedDeliveryDate = null }; this.context.Packages.Add(package); this.context.SaveChanges(); return(true); }
public IActionResult Create(PackageCreateBindingModel bindingModel) { return(this.View()); }