private HelpDesk_TicketCategory_vm mapEntityToViewModelTicketCategory(HelpDesk_TicketCategory EFTicketCat) { return(new HelpDesk_TicketCategory_vm { Id = EFTicketCat.Id, Category = EFTicketCat.Category }); }
public int EditCategoryById(int id, HelpDesk_TicketCategory category) { try { HelpDesk_TicketCategory oldCategory = _context.HelpDesk_TicketCategory.FirstOrDefault(x => x.Id == category.Id); if (oldCategory != null) { oldCategory.Category = category.Category; } _context.SaveChanges(); } catch (Exception ex) { _logger.Error(ex); } return(category.Id); }
public bool DeleteCategoryById(int id) { bool result = false; try { HelpDesk_TicketCategory oldCategory = _context.HelpDesk_TicketCategory.FirstOrDefault(x => x.Id == id); _context.HelpDesk_TicketCategory.Remove(oldCategory); _context.SaveChanges(); result = true; _logger.Info("Ticket category with id " + id + " was deleted."); } catch (Exception ex) { _logger.Error(ex); } return(result); }
public int CreateCategory(HelpDesk_TicketCategory category) { _context.HelpDesk_TicketCategory.Add(category); _context.SaveChanges(); return(category.Id); }