Exemplo n.º 1
0
        public static Listing CreateListing(CreateListingInput input)
        {
            Category c = Category.GetCategoryByName(input.CategoryName);

            if (c == null)
            {
                CreateCategoryInput cInput = new CreateCategoryInput(input.CategoryName);
                c = Category.CreateCategory(cInput);
            }

            Listing item = new Listing()
            {
                Username     = input.Username,
                ItemName     = input.ItemName,
                ItemContent  = input.ItemContent,
                ItemPrice    = input.ItemPrice,
                CategoryName = c.Name,
                CreateTime   = DateTime.Now,
            };

            Listing dbItem = StorageImpl.CreateListing(item);

            Category.UpdateCount(input.CategoryName, true);

            return(dbItem);
        }
Exemplo n.º 2
0
        public static Category CreateCategory(CreateCategoryInput input)
        {
            Category item = new Category()
            {
                Count = 0,
                Name  = input.Name
            };

            return(StorageImpl.CreateCategory(item));
        }