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); }
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); }
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)); }
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)); }