public ActionResult SetPayment(SneakerProductViewModel model) { HeroBreadSubTitle = "So let's talk about the price..."; model.Price = 500m; AddBreadcrumbNode(nameof(Payment)); return(this.ViewStep(3, model)); }
public async Task <ActionResult> Photos(SneakerProductViewModel model, bool rollback) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (rollback) { return(await SetDetails(model.ReferenceID)); } if (model.FormFiles != null && model.FormFiles.Any()) { foreach (var formFile in model.FormFiles) { if (formFile.Length <= 0) { continue; } var fileName = Path.ChangeExtension(Path.GetRandomFileName(), Path.GetExtension(formFile.FileName)); var filePath = Path.Combine(_environment.WebRootPath, "files/photos/products", fileName); using var stream = System.IO.File.Create(filePath); formFile.CopyTo(stream); model.Photos.Add(filePath); } } return(SetPayment(model)); }
public ActionResult SetShipping(SneakerProductViewModel model) { HeroBreadSubTitle = "Take care of the shipping. It better be worldwide"; if (model.ShippingInfo is null || !model.ShippingInfo.Any()) { model.ShippingInfo = Catalog.DefaultShippingInfo; } AddBreadcrumbNode(nameof(Shipping)); return(this.ViewStep(4, model)); }
public ActionResult Preview([FromServices] ISneakerProductService service, [FromForm] SneakerProductViewModel model, bool rollback) { if (rollback) { return(SetShipping(model)); } var sneakerProduct = model as SneakerProduct; var response = service.Store(sneakerProduct); if (response == null) { return(Problem()); } return(RedirectToAction("ProductItem", "Shop", new { productId = sneakerProduct.UniqueID })); }
public async Task <ActionResult> SetDetails(string referenceID) { var service = HttpContext.RequestServices.GetService <ISneakerReferenceService>(); if (service == null) { throw new NotImplementedException($"{nameof(ISneakerReferenceService)} not implemented"); } if (string.IsNullOrEmpty(referenceID)) { return(this.ViewStep(1, new SneakerProductViewModel())); } var reference = await service.FetchUniqueAsync(referenceID); if (reference == null) { return(this.ViewStep(1, new SneakerProductViewModel())); } var sneakerProduct = new SneakerProductViewModel { ReferenceID = reference.UniqueID, ModelSKU = reference.ManufactureSku, ModelName = reference.ModelName, BrandName = reference.BrandName, Description = reference.Description, Color = reference.Color, Price = reference.Price, Size = Catalog.SneakerSizesList[11] }; HeroBreadSubTitle = "Tell us about your sneakers. In details - the more the better"; return(this.ViewStep(1, sneakerProduct)); }
public ActionResult SetPhotos(SneakerProductViewModel model) { HeroBreadSubTitle = "Show buyers the best in your product"; AddBreadcrumbNode(nameof(Photos)); return(this.ViewStep(2, model)); }
public ActionResult Payment(SneakerProductViewModel model, bool rollback) { return(rollback ? SetPhotos(model) : SetShipping(model)); }
public static ActionResult ViewStep(this Controller controller, int stepIndex, SneakerProductViewModel model) { var steps = Steps(stepIndex); controller.ViewBag.Steps = steps; return(controller.View(steps.ActiveStep.View, model)); }
public ActionResult Details(SneakerProductViewModel model, bool rollback) { return(rollback ? RedirectToAction("NewProduct") : SetPhotos(model)); }
public ActionResult Shipping(SneakerProductViewModel model, bool rollback) { return(rollback ? SetPayment(model) : ShowPreview(model)); }
public ActionResult ShowPreview(SneakerProductViewModel model) { HeroBreadSubTitle = "Great job! If you are satisfied with it - send the whole thing to us, and we will publish it to all the sneakerheads around the world"; AddBreadcrumbNode(nameof(Preview)); return(this.ViewStep(5, model)); }