/// <summary> /// Delete a nav item object by id /// </summary> /// <param name="id">nav item id</param> /// <returns>The deleted object</returns> public NavItem Delete(int id) { NavItem navItem = _db.NavItems.Find(id); try { NavItemVersion navItemVersion = navItem.MapToNavItemVersion(); navItemVersion.IsDeleted = true; navItemVersion.CreatedById = _userId; navItemVersion.CreationDate = DateTime.Now; _db.NavItemVersions.Add(navItemVersion); int deleted = _db.SaveChanges(); if (deleted > 0) { _logger.LogInformation($"User: {userName} has deleted nav item with name: {navItem.EnName}"); } return(navItem); } catch (Exception ex) { return(null); } }