public bool AddAdminMenuItemRole(AdminMenuItemRoleDto dto) { if (!this.db.AdminMenuItemRoles.Any(x => x.DeletedOn.HasValue == false && x.Id == dto.Id)) { this.db.AdminMenuItemRoles.Add(new AdminMenuItemRole { CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, UpdatedBy = dto.UpdatedBy, Comment = dto.Comment, AdminMenuItemId = dto.AdminMenuItem.Id, AdminRoleId = dto.AdminRole.Id }); this.db.SaveChanges(); return true; } return false; }
public bool UpdateAdminMenuItemRole(AdminMenuItemRoleDto dto) { var adminMenuItemRole = this.db.AdminMenuItemRoles.FirstOrDefault(x => x.DeletedOn.HasValue == false && x.Id == dto.Id); if (adminMenuItemRole != null) { adminMenuItemRole.UpdatedOn = DateTime.Now; adminMenuItemRole.UpdatedBy = dto.UpdatedBy; adminMenuItemRole.Comment = dto.Comment; adminMenuItemRole.AdminMenuItemId = dto.AdminMenuItem.Id; adminMenuItemRole.AdminRoleId = dto.AdminRole.Id; this.db.SaveChanges(); return true; } return false; }