func (controller *HomeController) EditPost(productVM *ProductVM) mvc.ActionResultInterface { if len(productVM.Name) == 0 { productVM.Error = "Name can't be empty" return mvc.ShowView("", "", productVM) } productToUpdate := controller.findProduct(productVM.ProductId) isNewProduct := false if productToUpdate == nil { isNewProduct = true productAddSync.Lock() defer productAddSync.Unlock() productToUpdate = &Product{len(products) + 1, "", ""} products = append(products, productToUpdate) } productToUpdate.Name = productVM.Name productToUpdate.Description = productVM.Description if isNewProduct { return mvc.RedirectToAction("", "list", nil) } return mvc.ShowView("", "", ProductVMFromProduct(productToUpdate)) }
func (controller *HomeController) Edit(input *HomeEditInput) mvc.ActionResultInterface { product := controller.findProduct(input.ProductId) if product == nil { product = new(Product) } return mvc.ShowView("", "", ProductVMFromProduct(product)) }
func (controller *HomeController) List() mvc.ActionResultInterface { return mvc.ShowView("", "", products) }
func (controller *HomeController) Create() mvc.ActionResultInterface { return mvc.ShowView("", "edit", ProductVMFromProduct(new(Product))) }
func (controller *HomeController) Index() mvc.ActionResultInterface { return mvc.ShowView("", "", nil) }
func (controller *HomeController) Index() mvc.ActionResultInterface { return mvc.ShowView("", "", &Model{"John", &AddressModel{"City Center Plaza 516 Main St.", "Elgin", "OR", "USA"}}) }
func (controller *HomeController) Private() mvc.ActionResultInterface { return mvc.ShowView("", "", NewModel(authProvider.IsAuthenticated(controller.Request), false)) }
func (controller *HomeController) Index(input *HomeIndexInput) mvc.ActionResultInterface { return mvc.ShowView("", "", NewModel(authProvider.IsAuthenticated(controller.Request), input.Restricted)) }
func (controller *HomeController) IndexPost(model *Model) mvc.ActionResultInterface { return mvc.ShowView("", "", model.Name) }