UI is in place for insert.
This commit is contained in:
		
							parent
							
								
									89497e0cac
								
							
						
					
					
						commit
						aefc0a50bf
					
				@ -4,7 +4,9 @@
 | 
			
		||||
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
 | 
			
		||||
    <asp:ListView ID="catalogList" runat="server"
 | 
			
		||||
        DataKeyNames="Id" GroupItemCount="3"
 | 
			
		||||
        ItemType="eShopOnContainers.Core.Models.Catalog.CatalogItem" SelectMethod="GetCatalogDataAsync" DeleteMethod="DeleteCatalogItemAsync">
 | 
			
		||||
        ItemType="eShopOnContainers.Core.Models.Catalog.CatalogItem" 
 | 
			
		||||
        SelectMethod="GetCatalogDataAsync" 
 | 
			
		||||
        DeleteMethod="DeleteCatalogItemAsync">
 | 
			
		||||
        <EmptyDataTemplate>
 | 
			
		||||
            <div class="row">
 | 
			
		||||
                <span class="col-md-10 col-md-offset-1">There's nothing in the catalog to display at this time.
 | 
			
		||||
@ -44,4 +46,11 @@
 | 
			
		||||
            </div>
 | 
			
		||||
       </ItemTemplate>
 | 
			
		||||
    </asp:ListView>
 | 
			
		||||
    <div class="row">
 | 
			
		||||
        <span class="esh-catalog-label col-md-4 col-md-offset-2l">
 | 
			
		||||
            <a href="EditCatalogItem.aspx">
 | 
			
		||||
                Insert item
 | 
			
		||||
            </a>
 | 
			
		||||
        </span>
 | 
			
		||||
    </div>
 | 
			
		||||
</asp:Content>
 | 
			
		||||
 | 
			
		||||
@ -57,5 +57,55 @@
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
        </EditItemTemplate>
 | 
			
		||||
        <InsertItemTemplate>
 | 
			
		||||
            <div class="row form-inline">
 | 
			
		||||
                <div class="col-md-6">
 | 
			
		||||
                    <asp:FileUpload CssClass="esh-catalog-thumbnail" runat="server" />
 | 
			
		||||
                   
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="col-md-6">
 | 
			
		||||
                    <div class="container">
 | 
			
		||||
                        <div class="row">
 | 
			
		||||
                            <div class="col-md-12 form-group">
 | 
			
		||||
                                <label>Name</label>
 | 
			
		||||
                                <asp:TextBox runat="server" ID="itemName" CssClass="form-control form-input form-input-center" Text='<%# Bind("Name")%>' />
 | 
			
		||||
                            </div>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div class="row">
 | 
			
		||||
                            <div class="col-md-12 form-group">
 | 
			
		||||
                                <label for="ItemDescription">Description</label>
 | 
			
		||||
                                <asp:TextBox runat="server" name="ItemDescription" Width="100%" ID="ItemDescription" CssClass="form-control form-input form-input-center" Text='<%# Bind("Description")%>' />
 | 
			
		||||
                            </div>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div class="row">
 | 
			
		||||
                            <div class="col-md-12 form-group">
 | 
			
		||||
                                <label for="ItemPrice">Price</label>
 | 
			
		||||
                                <asp:TextBox runat="server" TextMode="Number" Width="75%" name="ItemPrice" ID="ItemPrice" CssClass="form-control form-input form-input-center" Text='<%# Bind("Price")%>' />
 | 
			
		||||
                            </div>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div class="row">
 | 
			
		||||
                            <div class="col-md-12 form-group">
 | 
			
		||||
                                <label class="control-label form-label" for="ItemBrand">Brand</label>
 | 
			
		||||
                                <asp:DropDownList ID="ItemBrand" runat="server" DataTextField="Brand" />
 | 
			
		||||
                            </div>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div class="row">
 | 
			
		||||
                            <div class="col-md-12 form-group">
 | 
			
		||||
                                <label class="control-label form-label" for="ItemType">Type</label>
 | 
			
		||||
                                <asp:DropDownList ID="ItemType" runat="server" DataTextField="Type" />
 | 
			
		||||
                            </div>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div class="row">
 | 
			
		||||
                            <div class="col-md-6 form-group">
 | 
			
		||||
                                <asp:LinkButton runat="server" Text="Update" CommandName="Update" />
 | 
			
		||||
                            </div>
 | 
			
		||||
                            <div class="col-md-6 form-group">
 | 
			
		||||
                                <asp:LinkButton runat="server" Text="Cancel" CommandName="Cancel" />
 | 
			
		||||
                            </div>
 | 
			
		||||
                        </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
        </InsertItemTemplate>
 | 
			
		||||
    </asp:FormView>
 | 
			
		||||
</asp:Content>
 | 
			
		||||
 | 
			
		||||
@ -32,17 +32,24 @@ namespace eShopOnContainers.Catalog.WebForms
 | 
			
		||||
 | 
			
		||||
        // The id parameter should match the DataKeyNames value set on the control
 | 
			
		||||
        // or be decorated with a value provider attribute, e.g. [QueryString]int id
 | 
			
		||||
        public async Task<CatalogItem> GetCatalogItemAsync([QueryString]int id)
 | 
			
		||||
        public async Task<CatalogItem> GetCatalogItemAsync([QueryString]int? id)
 | 
			
		||||
        {
 | 
			
		||||
            // TODO: If null, go into insert mode.
 | 
			
		||||
            var itemToEdit = await catalog?.GetCatalogItemAsync(id.ToString());
 | 
			
		||||
            return itemToEdit;
 | 
			
		||||
            if (id.HasValue)
 | 
			
		||||
            {
 | 
			
		||||
                var itemToEdit = await catalog?.GetCatalogItemAsync(id.ToString());
 | 
			
		||||
                return itemToEdit;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                EditCatalogItemForm.ChangeMode(FormViewMode.Insert);
 | 
			
		||||
                return new CatalogItem();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // The id parameter name should match the DataKeyNames value set on the control
 | 
			
		||||
        public void UpdateCatalogItemAsync(int id)
 | 
			
		||||
        {
 | 
			
		||||
            eShopOnContainers.Core.Models.Catalog.CatalogItem item = null;
 | 
			
		||||
            CatalogItem item = null;
 | 
			
		||||
            // Load the item here, e.g. item = MyDataLayer.Find(id);
 | 
			
		||||
            if (item == null)
 | 
			
		||||
            {
 | 
			
		||||
@ -50,11 +57,11 @@ namespace eShopOnContainers.Catalog.WebForms
 | 
			
		||||
                ModelState.AddModelError("", String.Format("Item with id {0} was not found", id));
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            TryUpdateModel(item);
 | 
			
		||||
            if (ModelState.IsValid)
 | 
			
		||||
            
 | 
			
		||||
            if (TryUpdateModel(item) && (ModelState.IsValid))
 | 
			
		||||
            {
 | 
			
		||||
                // Save changes here, e.g. MyDataLayer.SaveChanges();
 | 
			
		||||
 | 
			
		||||
                // Send the item to the Catalog Service.
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user