private NavBarDTO ToDTO(NavBarEntity entity) { NavBarDTO dto = new NavBarDTO(); dto.CreateTime = entity.CreateTime; dto.Id = entity.Id; dto.MenuName = entity.MenuName; dto.ParentId = entity.ParentId; dto.Sort = entity.Sort; dto.Url = entity.Url; dto.MenuId = entity.MenuId; dto.IsLock = entity.IsLock; return(dto); }
public async Task <long> AddChild(string menuName, string url, long sort, long parentId) { using (MyDbContext dbc = new MyDbContext()) { NavBarEntity entity = new NavBarEntity(); entity.MenuId = 0; entity.MenuName = menuName; entity.Url = url; entity.Sort = sort; entity.ParentId = parentId; dbc.NavBars.Add(entity); await dbc.SaveChangesAsync(); return(entity.Id); } }