public bool AddAdminMenuItem(AdminMenuItemDto dto) { if (!this.db.AdminMenuItems.Any(x => x.DeletedOn.HasValue == false && x.Name.Trim() == dto.Name.Trim())) { var adminMenuItem = new AdminMenuItem { CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, UpdatedBy = dto.UpdatedBy, Comment = dto.Comment, Name = dto.Name, Description = dto.Description, NavigateUrl = dto.NavigateUrl, DisplayOrder = dto.DisplayOrder }; if (dto.ParentAdminMenuItem != null) { adminMenuItem.ParentAdminMenuItemId = dto.ParentAdminMenuItem.Id; } this.db.AdminMenuItems.Add(adminMenuItem); this.db.SaveChanges(); return true; } return false; }
public bool UpdateAdminMenuItem(AdminMenuItemDto dto) { var updateAdminMenuItem = this.db.AdminMenuItems.FirstOrDefault(x => x.DeletedOn.HasValue == false && x.Id == dto.Id); if (updateAdminMenuItem != null) { updateAdminMenuItem.UpdatedOn = DateTime.Now; updateAdminMenuItem.UpdatedBy = dto.UpdatedBy; updateAdminMenuItem.Comment = dto.Comment; updateAdminMenuItem.ParentAdminMenuItemId = dto.ParentAdminMenuItem.Id; updateAdminMenuItem.Name = dto.Name; updateAdminMenuItem.Description = dto.Description; updateAdminMenuItem.NavigateUrl = dto.NavigateUrl; updateAdminMenuItem.DisplayOrder = dto.DisplayOrder; this.db.SaveChanges(); return true; } return false; }
public bool DeleteAdminMenuItem(AdminMenuItemDto dto) { var updateAdminMenuItem = this.db.AdminMenuItems.FirstOrDefault(x => x.DeletedOn.HasValue == false && x.Id == dto.Id); if (updateAdminMenuItem != null) { updateAdminMenuItem.DeletedOn = DateTime.Now; updateAdminMenuItem.UpdatedBy = dto.UpdatedBy; updateAdminMenuItem.Comment = dto.Comment; this.db.SaveChanges(); return true; } return false; }