Ejemplo n.º 1
0
        public static LibraryItemVM MappForEditToVM(DataLibrary.Models.LibraryItemModel item)
        {
            var model    = new LibraryItemVM();
            var category = new Category();

            if (item.CategoryId > 0)
            {
                category = new Category()
                {
                    Id = CategoryProcessor.EditCategory(item.CategoryId).Id, CategoryName = CategoryProcessor.EditCategory(item.CategoryId).CategoryName
                };
            }

            model.Author         = item.Author;
            model.BorrowDate     = item.BorrowDate;
            model.Borrower       = item.Borrower;
            model.Category       = category;
            model.Id             = item.Id;
            model.IsBorrowable   = item.IsBorrowable;
            model.Pages          = item.Pages;
            model.RunTimeMinutes = item.RunTimeMinutes;
            model.Title          = item.Title;
            model.Type           = item.Type;

            return(model);
        }
Ejemplo n.º 2
0
        public static List <LibraryItemVM> MappLibraryItemToVM(List <DataLibrary.Models.LibraryItemModel> input)
        {
            var output = new List <LibraryItemVM>();

            foreach (var item in input)
            {
                var model    = new LibraryItemVM();
                var category = new Category();
                if (item.CategoryId > 0)
                {
                    category = new Category()
                    {
                        Id = CategoryProcessor.EditCategory(item.CategoryId).Id, CategoryName = CategoryProcessor.EditCategory(item.CategoryId).CategoryName
                    };
                }
                model.Author         = item.Author;
                model.BorrowDate     = item.BorrowDate;
                model.Borrower       = item.Borrower;
                model.Category       = category;
                model.Id             = item.Id;
                model.IsBorrowable   = item.IsBorrowable;
                model.Pages          = item.Pages;
                model.RunTimeMinutes = item.RunTimeMinutes;
                model.Title          = item.Title;
                model.Type           = item.Type;
                output.Add(model);
            }


            return(output);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit([FromForm] CategoryForm category, string budgetId)
        {
            var modifiedBudget = await _categoryProcessor.EditCategory(category, budgetId);

            if (modifiedBudget == null)
            {
                return(NotFound());
            }
            return(Ok(modifiedBudget));
        }
Ejemplo n.º 4
0
        public static Category GetCategoryById(int id)
        {
            var category     = new Category();
            var tempCategory = CategoryProcessor.EditCategory(id);

            category.CategoryName = tempCategory.CategoryName;
            category.Id           = tempCategory.Id;

            return(category);
        }
        public ActionResult Edit(int id)
        {
            var output = CategoryProcessor.EditCategory(id);
            var model  = new ConsidÖvning.Models.Category();

            model.Id           = output.Id;
            model.CategoryName = output.CategoryName;

            return(View(model));
        }